@lesjoursfr/gifsicle-wrapper 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ import { execa } from "execa";
2
+ import { mkdir, rm } from "fs/promises";
3
+ import process from "process";
4
+ import { x as extract } from "tar";
5
+ import { temporaryFile } from "tempy";
6
+ import { gifsicleSourcePath, gifsicleWrapper } from "./wrapper.js";
7
+ async function buildFromSource(file, cmd) {
8
+ const temporary = temporaryFile();
9
+ console.log(`use the temporary folder : ${temporary}`);
10
+ await mkdir(temporary, { recursive: true });
11
+ await extract({ file: file, cwd: temporary, strip: 1 });
12
+ for (const x of cmd) {
13
+ await execa(x, { cwd: temporary, shell: true });
14
+ }
15
+ await rm(temporary, { recursive: true });
16
+ }
17
+ (async () => {
18
+ try {
19
+ await gifsicleWrapper.run(["--version"]);
20
+ console.log("gifsicle pre-build test passed successfully");
21
+ }
22
+ catch (error) {
23
+ if (error instanceof Error) {
24
+ console.warn(error.message);
25
+ }
26
+ console.warn("gifsicle pre-build test failed");
27
+ console.info("compiling from source");
28
+ try {
29
+ const source = gifsicleSourcePath;
30
+ const destination = gifsicleWrapper.dest;
31
+ await buildFromSource(source, [
32
+ "autoreconf -ivf",
33
+ `./configure --disable-gifview --disable-gifdiff --prefix="${destination}" --bindir="${destination}"`,
34
+ "make install",
35
+ ]);
36
+ console.log("gifsicle built successfully");
37
+ }
38
+ catch (error) {
39
+ if (error instanceof Error) {
40
+ console.error(error.stack);
41
+ }
42
+ process.exit(1);
43
+ }
44
+ }
45
+ })();
@@ -0,0 +1,11 @@
1
+ import BinWrapper from "@lesjoursfr/bin-wrapper";
2
+ import { platform } from "process";
3
+ import { fileURLToPath } from "url";
4
+ const version = "1.94";
5
+ const base = `https://raw.githubusercontent.com/lesjoursfr/gifsicle-wrapper/main/vendor/v${version}`;
6
+ export const gifsicleWrapper = new BinWrapper({ strip: 0 });
7
+ gifsicleWrapper.addSrc(`${base}/linux/x64/gifsicle.tar.gz`, "linux", "x64");
8
+ gifsicleWrapper.setDest(fileURLToPath(new URL("../vendor", import.meta.url)));
9
+ gifsicleWrapper.setUse(platform === "win32" ? "gifsicle.exe" : "gifsicle");
10
+ gifsicleWrapper.setVersion(`>=${version}`);
11
+ export const gifsicleSourcePath = fileURLToPath(new URL(`../vendor/v${version}/source/gifsicle.tar.gz`, import.meta.url));
@@ -0,0 +1,17 @@
1
+ import { Gifsicle } from "../gifsicle.js";
2
+ /**
3
+ * Convert to 8-bit greyscale.
4
+ *
5
+ * @param {Boolean} [greyscale=true]
6
+ * @returns {Gifsicle}
7
+ * @throws {TypeError} Invalid parameters
8
+ */
9
+ export declare function greyscale(this: Gifsicle, greyscale: boolean | undefined): Gifsicle;
10
+ /**
11
+ * Alternative spelling of `greyscale`.
12
+ *
13
+ * @param {Boolean} [grayscale=true]
14
+ * @returns {Gifsicle}
15
+ * @throws {TypeError} Invalid parameters
16
+ */
17
+ export declare function grayscale(this: Gifsicle, grayscale: boolean | undefined): Gifsicle;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Convert to 8-bit greyscale.
3
+ *
4
+ * @param {Boolean} [greyscale=true]
5
+ * @returns {Gifsicle}
6
+ * @throws {TypeError} Invalid parameters
7
+ */
8
+ export function greyscale(greyscale) {
9
+ if (greyscale !== undefined) {
10
+ this.options.greyscale = greyscale;
11
+ }
12
+ else {
13
+ this.options.greyscale = true;
14
+ }
15
+ return this;
16
+ }
17
+ /**
18
+ * Alternative spelling of `greyscale`.
19
+ *
20
+ * @param {Boolean} [grayscale=true]
21
+ * @returns {Gifsicle}
22
+ * @throws {TypeError} Invalid parameters
23
+ */
24
+ export function grayscale(grayscale) {
25
+ return this.greyscale(grayscale);
26
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function readFile(input: string | Buffer): Buffer;
@@ -0,0 +1,11 @@
1
+ import { readFileSync } from "fs";
2
+ import { isGif } from "../toolbox/is-gif.js";
3
+ export function readFile(input) {
4
+ if (typeof input === "string") {
5
+ input = readFileSync(input);
6
+ }
7
+ if (!isGif(input)) {
8
+ throw new TypeError("Expected 'input' to be a gif file");
9
+ }
10
+ return input;
11
+ }
@@ -0,0 +1,26 @@
1
+ import { Gifsicle } from "../gifsicle.js";
2
+ /**
3
+ * Optimization levels.
4
+ */
5
+ export declare enum OptimizationLevel {
6
+ O1 = "O1",
7
+ O2 = "O2",
8
+ O3 = "O3"
9
+ }
10
+ /**
11
+ * Optimization options.
12
+ */
13
+ export type OptimizeOptions = {
14
+ level?: OptimizationLevel;
15
+ lossiness?: number;
16
+ };
17
+ /**
18
+ * Optimize the gif.
19
+ *
20
+ * @param {Object} [options]
21
+ * @param {OptimizationLevel} [options.level=OptimizationLevel.O1] - the optimization level.
22
+ * @param {Number} [options.lossiness=20] - the lossiness value to shrink the number of colors [0,200].
23
+ * @returns {Gifsicle}
24
+ * @throws {TypeError} Invalid parameters
25
+ */
26
+ export declare function optimize(this: Gifsicle, options: OptimizeOptions | undefined): Gifsicle;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Optimization levels.
3
+ */
4
+ /* eslint-disable no-unused-vars */
5
+ export var OptimizationLevel;
6
+ (function (OptimizationLevel) {
7
+ OptimizationLevel["O1"] = "O1";
8
+ OptimizationLevel["O2"] = "O2";
9
+ OptimizationLevel["O3"] = "O3";
10
+ })(OptimizationLevel || (OptimizationLevel = {}));
11
+ /**
12
+ * Optimize the gif.
13
+ *
14
+ * @param {Object} [options]
15
+ * @param {OptimizationLevel} [options.level=OptimizationLevel.O1] - the optimization level.
16
+ * @param {Number} [options.lossiness=20] - the lossiness value to shrink the number of colors [0,200].
17
+ * @returns {Gifsicle}
18
+ * @throws {TypeError} Invalid parameters
19
+ */
20
+ export function optimize(options) {
21
+ // Default options
22
+ this.options.optimize = { level: OptimizationLevel.O1, lossiness: 20 };
23
+ // Process parameters
24
+ if (options !== undefined) {
25
+ // Level
26
+ if (options.level !== undefined) {
27
+ this.options.optimize.level = options.level;
28
+ }
29
+ // Lossiness
30
+ if (options.lossiness !== undefined) {
31
+ if (Number.isInteger(options.lossiness) && options.lossiness > 0 && options.lossiness < 200) {
32
+ this.options.optimize.lossiness = options.lossiness;
33
+ }
34
+ else {
35
+ throw new TypeError("Expected 'lossiness' to be an integer in the range [0,200]");
36
+ }
37
+ }
38
+ }
39
+ return this;
40
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" />
2
+ import { Gifsicle } from "../gifsicle.js";
3
+ /**
4
+ * Save the result in a file.
5
+ *
6
+ * @param {String} [fileOut]
7
+ */
8
+ export declare function toFile(this: Gifsicle, fileOut: string): Promise<void>;
9
+ /**
10
+ * Get the result file as a Buffer.
11
+ *
12
+ * @returns {Buffer}
13
+ */
14
+ export declare function toBuffer(this: Gifsicle): Promise<Buffer>;
@@ -0,0 +1,53 @@
1
+ import { execa } from "execa";
2
+ import { writeFileSync } from "fs";
3
+ import { gifsicleWrapper } from "../wrapper.js";
4
+ import { computeCroppingPoint } from "./resize.js";
5
+ async function processFile(input, options) {
6
+ const args = ["--no-warnings", "--no-app-extensions"];
7
+ if (options.greyscale === true) {
8
+ args.push("--use-colormap=gray");
9
+ }
10
+ if (options.crop !== undefined) {
11
+ const { x, y } = computeCroppingPoint(input, options.crop);
12
+ args.push(`--crop=${x}, ${y}+${options.crop.width}x${options.crop.height}`);
13
+ }
14
+ if (options.resize !== undefined) {
15
+ if (options.resize.width !== undefined || options.resize.height !== undefined) {
16
+ if (options.resize.withoutEnlargement === true) {
17
+ args.push(`--resize-fit=${options.resize.width || "_"}x${options.resize.height || "_"}`);
18
+ }
19
+ else {
20
+ args.push(`--resize-touch=${options.resize.width || "_"}x${options.resize.height || "_"}`);
21
+ }
22
+ }
23
+ }
24
+ if (options.optimize !== undefined) {
25
+ if (options.optimize.level !== undefined) {
26
+ args.push(`-${options.optimize.level}`);
27
+ }
28
+ if (options.optimize.lossiness !== undefined) {
29
+ args.push(`--lossy=${options.optimize.lossiness}`);
30
+ }
31
+ }
32
+ const { stdout } = await execa(gifsicleWrapper.path, args, {
33
+ encoding: null,
34
+ input,
35
+ });
36
+ return stdout;
37
+ }
38
+ /**
39
+ * Save the result in a file.
40
+ *
41
+ * @param {String} [fileOut]
42
+ */
43
+ export async function toFile(fileOut) {
44
+ writeFileSync(fileOut, await processFile(this.input, this.options));
45
+ }
46
+ /**
47
+ * Get the result file as a Buffer.
48
+ *
49
+ * @returns {Buffer}
50
+ */
51
+ export async function toBuffer() {
52
+ return processFile(this.input, this.options);
53
+ }
@@ -0,0 +1,71 @@
1
+ /// <reference types="node" />
2
+ import { Gifsicle } from "../gifsicle.js";
3
+ /**
4
+ * Reduction kernels.
5
+ */
6
+ export declare enum ReductionKernel {
7
+ sample = "sample",
8
+ mix = "mix",
9
+ catrom = "catrom",
10
+ mitchell = "mitchell",
11
+ lanczos2 = "lanczos2",
12
+ lanczos3 = "lanczos3"
13
+ }
14
+ /**
15
+ * Position modes for cropping.
16
+ */
17
+ export declare enum CroppingPosition {
18
+ center = "center",
19
+ top = "top",
20
+ right = "right",
21
+ bottom = "bottom",
22
+ left = "left",
23
+ topRight = "topRight",
24
+ bottomRight = "bottomRight",
25
+ bottomLeft = "bottomLeft",
26
+ topLeft = "topLeft"
27
+ }
28
+ /**
29
+ * Resize options.
30
+ */
31
+ export type ResizeOptions = {
32
+ kernel: ReductionKernel | undefined;
33
+ withoutEnlargement: boolean | undefined;
34
+ };
35
+ /**
36
+ * Cropping options.
37
+ */
38
+ export type CroppingOptions = {
39
+ position: CroppingPosition | undefined;
40
+ };
41
+ /**
42
+ * Resize image to `width`, `height` or `width x height`.
43
+ *
44
+ * @param {Number} [width] - pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
45
+ * @param {Number} [height] - pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
46
+ * @param {Object} [options]
47
+ * @param {ReductionKernel} [options.kernel=ReductionKernel.lanczos3] - the kernel to use for image reduction.
48
+ * @param {Boolean} [options.withoutEnlargement=false] - do not enlarge if the width *or* height are already less than the specified dimensions, equivalent to GraphicsMagick's `>` geometry option. *
49
+ * @returns {Gifsicle}
50
+ * @throws {TypeError} Invalid parameters
51
+ */
52
+ export declare function resize(this: Gifsicle, width: number | undefined, height: number | undefined, options: ResizeOptions | undefined): Gifsicle;
53
+ /**
54
+ * Crop the image to `width x height`.
55
+ *
56
+ * @param {number} [width] - pixels wide the resultant image should be.
57
+ * @param {number} [height] - pixels high the resultant image should be.
58
+ * @param {Object} [options]
59
+ * @param {CroppingPosition} [options.position=CroppingPosition.center] - position of the cropping rectangle.
60
+ * @returns {Gifsicle}
61
+ * @throws {TypeError} Invalid parameters
62
+ */
63
+ export declare function crop(this: Gifsicle, width: number, height: number, options: CroppingOptions | undefined): Gifsicle;
64
+ export declare function computeCroppingPoint(input: Buffer, crop: {
65
+ width: number;
66
+ height: number;
67
+ position: CroppingPosition;
68
+ }): {
69
+ x: number;
70
+ y: number;
71
+ };
@@ -0,0 +1,155 @@
1
+ import sizeOf from "image-size";
2
+ /**
3
+ * Reduction kernels.
4
+ */
5
+ /* eslint-disable no-unused-vars */
6
+ export var ReductionKernel;
7
+ (function (ReductionKernel) {
8
+ ReductionKernel["sample"] = "sample";
9
+ ReductionKernel["mix"] = "mix";
10
+ ReductionKernel["catrom"] = "catrom";
11
+ ReductionKernel["mitchell"] = "mitchell";
12
+ ReductionKernel["lanczos2"] = "lanczos2";
13
+ ReductionKernel["lanczos3"] = "lanczos3";
14
+ })(ReductionKernel || (ReductionKernel = {}));
15
+ /* eslint-enable no-unused-vars */
16
+ /**
17
+ * Position modes for cropping.
18
+ */
19
+ /* eslint-disable no-unused-vars */
20
+ export var CroppingPosition;
21
+ (function (CroppingPosition) {
22
+ CroppingPosition["center"] = "center";
23
+ CroppingPosition["top"] = "top";
24
+ CroppingPosition["right"] = "right";
25
+ CroppingPosition["bottom"] = "bottom";
26
+ CroppingPosition["left"] = "left";
27
+ CroppingPosition["topRight"] = "topRight";
28
+ CroppingPosition["bottomRight"] = "bottomRight";
29
+ CroppingPosition["bottomLeft"] = "bottomLeft";
30
+ CroppingPosition["topLeft"] = "topLeft";
31
+ })(CroppingPosition || (CroppingPosition = {}));
32
+ /**
33
+ * Resize image to `width`, `height` or `width x height`.
34
+ *
35
+ * @param {Number} [width] - pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
36
+ * @param {Number} [height] - pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
37
+ * @param {Object} [options]
38
+ * @param {ReductionKernel} [options.kernel=ReductionKernel.lanczos3] - the kernel to use for image reduction.
39
+ * @param {Boolean} [options.withoutEnlargement=false] - do not enlarge if the width *or* height are already less than the specified dimensions, equivalent to GraphicsMagick's `>` geometry option. *
40
+ * @returns {Gifsicle}
41
+ * @throws {TypeError} Invalid parameters
42
+ */
43
+ export function resize(width, height, options) {
44
+ // Default options
45
+ this.options.resize = { kernel: ReductionKernel.lanczos3, withoutEnlargement: false };
46
+ // Process parameters
47
+ if (width !== undefined) {
48
+ if (Number.isInteger(width) && width > 0) {
49
+ this.options.resize.width = width;
50
+ }
51
+ else {
52
+ throw new TypeError("Expected 'width' to be a positive integer");
53
+ }
54
+ }
55
+ if (height !== undefined) {
56
+ if (Number.isInteger(height) && height > 0) {
57
+ this.options.resize.height = height;
58
+ }
59
+ else {
60
+ throw new TypeError("Expected 'height' to be a positive integer");
61
+ }
62
+ }
63
+ if (options !== undefined) {
64
+ // Kernel
65
+ if (options.kernel !== undefined) {
66
+ this.options.resize.kernel = options.kernel;
67
+ }
68
+ // Without enlargement
69
+ if (options.withoutEnlargement !== undefined) {
70
+ this.options.resize.withoutEnlargement = options.withoutEnlargement;
71
+ }
72
+ }
73
+ return this;
74
+ }
75
+ /**
76
+ * Crop the image to `width x height`.
77
+ *
78
+ * @param {number} [width] - pixels wide the resultant image should be.
79
+ * @param {number} [height] - pixels high the resultant image should be.
80
+ * @param {Object} [options]
81
+ * @param {CroppingPosition} [options.position=CroppingPosition.center] - position of the cropping rectangle.
82
+ * @returns {Gifsicle}
83
+ * @throws {TypeError} Invalid parameters
84
+ */
85
+ export function crop(width, height, options) {
86
+ // Default options
87
+ this.options.crop = { width: 0, height: 0, position: CroppingPosition.center };
88
+ // Process parameters
89
+ if (Number.isInteger(width) && width > 0) {
90
+ this.options.crop.width = width;
91
+ }
92
+ else {
93
+ throw new TypeError("Expected 'width' to be a positive integer");
94
+ }
95
+ if (Number.isInteger(height) && height > 0) {
96
+ this.options.crop.height = height;
97
+ }
98
+ else {
99
+ throw new TypeError("Expected 'height' to be a positive integer");
100
+ }
101
+ if (options !== undefined) {
102
+ // Position
103
+ if (options.position !== undefined) {
104
+ this.options.crop.position = options.position;
105
+ }
106
+ }
107
+ return this;
108
+ }
109
+ export function computeCroppingPoint(input, crop) {
110
+ const size = sizeOf(input);
111
+ if (size.width === undefined || size.height === undefined) {
112
+ throw new Error("Can't compute the image size");
113
+ }
114
+ let px = 0;
115
+ let py = 0;
116
+ switch (crop.position) {
117
+ case CroppingPosition.center:
118
+ px = Math.floor((size.width - crop.width) / 2);
119
+ py = Math.floor((size.height - crop.height) / 2);
120
+ break;
121
+ case CroppingPosition.top:
122
+ px = Math.floor((size.width - crop.width) / 2);
123
+ py = 0;
124
+ break;
125
+ case CroppingPosition.right:
126
+ px = size.width - crop.width;
127
+ py = Math.floor((size.height - crop.height) / 2);
128
+ break;
129
+ case CroppingPosition.bottom:
130
+ px = Math.floor((size.width - crop.width) / 2);
131
+ py = size.height - crop.height;
132
+ break;
133
+ case CroppingPosition.left:
134
+ px = 0;
135
+ py = Math.floor((size.height - crop.height) / 2);
136
+ break;
137
+ case CroppingPosition.topRight:
138
+ px = size.width - crop.width;
139
+ py = 0;
140
+ break;
141
+ case CroppingPosition.bottomRight:
142
+ px = size.width - crop.width;
143
+ py = size.height - crop.height;
144
+ break;
145
+ case CroppingPosition.bottomLeft:
146
+ px = 0;
147
+ py = size.height - crop.height;
148
+ break;
149
+ case CroppingPosition.topLeft:
150
+ px = 0;
151
+ py = 0;
152
+ break;
153
+ }
154
+ return { x: px, y: py };
155
+ }
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import { grayscale, greyscale } from "./core/color.js";
3
+ import { OptimizeOptions, optimize } from "./core/optimize.js";
4
+ import { toBuffer, toFile } from "./core/output.js";
5
+ import { CroppingPosition, ReductionKernel, crop, resize } from "./core/resize.js";
6
+ export interface GifsicleInternalOptions {
7
+ greyscale?: boolean;
8
+ resize?: {
9
+ width?: number;
10
+ height?: number;
11
+ kernel: ReductionKernel;
12
+ withoutEnlargement: boolean;
13
+ };
14
+ crop?: {
15
+ width: number;
16
+ height: number;
17
+ position: CroppingPosition;
18
+ };
19
+ optimize?: OptimizeOptions;
20
+ }
21
+ /**
22
+ * Export Gifsicle class.
23
+ */
24
+ export declare class Gifsicle {
25
+ options: GifsicleInternalOptions;
26
+ input: Buffer;
27
+ constructor(input: string | Buffer);
28
+ greyscale: typeof greyscale;
29
+ grayscale: typeof grayscale;
30
+ resize: typeof resize;
31
+ crop: typeof crop;
32
+ optimize: typeof optimize;
33
+ toFile: typeof toFile;
34
+ toBuffer: typeof toBuffer;
35
+ }
@@ -0,0 +1,23 @@
1
+ import { grayscale, greyscale } from "./core/color.js";
2
+ import { readFile } from "./core/input.js";
3
+ import { optimize } from "./core/optimize.js";
4
+ import { toBuffer, toFile } from "./core/output.js";
5
+ import { crop, resize } from "./core/resize.js";
6
+ /**
7
+ * Export Gifsicle class.
8
+ */
9
+ export class Gifsicle {
10
+ options;
11
+ input;
12
+ constructor(input) {
13
+ this.input = readFile(input);
14
+ this.options = {};
15
+ }
16
+ greyscale = greyscale;
17
+ grayscale = grayscale;
18
+ resize = resize;
19
+ crop = crop;
20
+ optimize = optimize;
21
+ toFile = toFile;
22
+ toBuffer = toBuffer;
23
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { OptimizationLevel } from "./core/optimize.js";
3
+ import { CroppingPosition, ReductionKernel } from "./core/resize.js";
4
+ import { Gifsicle } from "./gifsicle.js";
5
+ declare function gifsicle(input: string | Buffer): Gifsicle;
6
+ declare namespace gifsicle {
7
+ var kernel: typeof ReductionKernel;
8
+ var position: typeof CroppingPosition;
9
+ var level: typeof OptimizationLevel;
10
+ }
11
+ export default gifsicle;
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { OptimizationLevel } from "./core/optimize.js";
2
+ import { CroppingPosition, ReductionKernel } from "./core/resize.js";
3
+ import { Gifsicle } from "./gifsicle.js";
4
+ function gifsicle(input) {
5
+ return new Gifsicle(input);
6
+ }
7
+ gifsicle.kernel = ReductionKernel;
8
+ gifsicle.position = CroppingPosition;
9
+ gifsicle.level = OptimizationLevel;
10
+ export default gifsicle;
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function isGif(buffer: Buffer): boolean;
@@ -0,0 +1,8 @@
1
+ // Based on isGif function from https://github.com/sindresorhus/is-gif
2
+ // https://github.com/sindresorhus/is-gif/blob/main/index.js
3
+ export function isGif(buffer) {
4
+ if (!buffer || buffer.length < 3) {
5
+ return false;
6
+ }
7
+ return buffer[0] === 0x47 && buffer[1] === 0x49 && buffer[2] === 0x46;
8
+ }
@@ -0,0 +1,3 @@
1
+ import BinWrapper from "@lesjoursfr/bin-wrapper";
2
+ export declare const gifsicleWrapper: BinWrapper;
3
+ export declare const gifsicleSourcePath: string;
package/lib/wrapper.js ADDED
@@ -0,0 +1,11 @@
1
+ import BinWrapper from "@lesjoursfr/bin-wrapper";
2
+ import { platform } from "process";
3
+ import { fileURLToPath } from "url";
4
+ const version = "1.94";
5
+ const base = `https://raw.githubusercontent.com/lesjoursfr/gifsicle-wrapper/main/vendor/v${version}`;
6
+ export const gifsicleWrapper = new BinWrapper({ strip: 0 });
7
+ gifsicleWrapper.addSrc(`${base}/linux/x64/gifsicle.tar.gz`, "linux", "x64");
8
+ gifsicleWrapper.setDest(fileURLToPath(new URL("../vendor", import.meta.url)));
9
+ gifsicleWrapper.setUse(platform === "win32" ? "gifsicle.exe" : "gifsicle");
10
+ gifsicleWrapper.setVersion(`>=${version}`);
11
+ export const gifsicleSourcePath = fileURLToPath(new URL(`../vendor/v${version}/source/gifsicle.tar.gz`, import.meta.url));
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Les Jours (github.com/lesjoursfr)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@lesjoursfr/gifsicle-wrapper",
3
+ "version": "4.1.5",
4
+ "description": "Wrapper for Gifsicle",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/lesjoursfr/gifsicle-wrapper.git"
9
+ },
10
+ "homepage": "https://github.com/lesjoursfr/gifsicle-wrapper#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/lesjoursfr/gifsicle-wrapper/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "engines": {
18
+ "node": "18.x || 20.x"
19
+ },
20
+ "exports": "./lib/index.js",
21
+ "types": "./lib/index.d.ts",
22
+ "files": [
23
+ "install/**/*",
24
+ "vendor/v1.94/source/gifsicle.tar.gz",
25
+ "lib/**/*",
26
+ "src/**/*"
27
+ ],
28
+ "scripts": {
29
+ "freshlock": "rm -rf node_modules/ && rm .yarn/install-state.gz && rm yarn.lock && yarn",
30
+ "postinstall": "node install/install.js",
31
+ "check-lint": "eslint . --ext .js,.jsx,.ts,.tsx",
32
+ "check-format": "prettier --check \"**/*.{ts,js,cjs,mjs,json,yml,md}\"",
33
+ "check-tsc": "tsc --noEmit",
34
+ "lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
35
+ "format": "prettier --write \"**/*.{ts,js,cjs,mjs,json,yml,md}\"",
36
+ "build-postinstall": "tsc --project tsconfig.install.json",
37
+ "build": "tsc",
38
+ "test": "NODE_OPTIONS='--loader=ts-node/esm' mocha"
39
+ },
40
+ "keywords": [
41
+ "gif",
42
+ "gifsicle",
43
+ "image",
44
+ "img",
45
+ "compress",
46
+ "resize",
47
+ "minify",
48
+ "optimize"
49
+ ],
50
+ "type": "module",
51
+ "dependencies": {
52
+ "@lesjoursfr/bin-wrapper": "^12.1.5",
53
+ "execa": "^8.0.1",
54
+ "image-size": "^1.1.1",
55
+ "tar": "^6.2.0",
56
+ "tempy": "^3.1.0"
57
+ },
58
+ "devDependencies": {
59
+ "@tsconfig/node18": "^18.2.2",
60
+ "@types/mocha": "^10.0.6",
61
+ "@types/node": "^20.11.15",
62
+ "@types/tar": "^6.1.11",
63
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
64
+ "@typescript-eslint/parser": "^6.20.0",
65
+ "eslint": "^8.56.0",
66
+ "eslint-config-prettier": "^9.1.0",
67
+ "mocha": "^10.2.0",
68
+ "prettier": "^3.2.4",
69
+ "ts-node": "^10.9.2",
70
+ "typescript": "^5.3.3"
71
+ },
72
+ "packageManager": "yarn@4.1.0"
73
+ }
package/readme.md ADDED
@@ -0,0 +1,47 @@
1
+ [![NPM version](https://badge.fury.io/js/@lesjoursfr%2Fgifsicle-wrapper.svg)](http://badge.fury.io/js/@lesjoursfr%2Fgifsicle-wrapper)
2
+ [![QC Checks](https://github.com/lesjoursfr/gifsicle-wrapper/actions/workflows/quality-control.yml/badge.svg)](https://github.com/lesjoursfr/gifsicle-wrapper/actions/workflows/quality-control.yml)
3
+
4
+ # @lesjoursfr/gifsicle-wrapper
5
+
6
+ [Gifsicle](https://www.lcdf.org/gifsicle/) wrapper
7
+
8
+ ## Usage
9
+
10
+ Resize a Gif :
11
+
12
+ ```javascript
13
+ const Gifsicle = require("@lesjoursfr/gifsicle-wrapper");
14
+
15
+ (async () => {
16
+ await Gifsicle(path.join(__dirname, "test.gif"))
17
+ .resize(600, 600, {
18
+ kernel: gifsicle.kernel.lanczos3,
19
+ withoutEnlargement: true,
20
+ })
21
+ .toFile(path.join(__dirname, "test-resized.gif"));
22
+ })();
23
+ ```
24
+
25
+ Change colors to greyscale :
26
+
27
+ ```javascript
28
+ const Gifsicle = require("@lesjoursfr/gifsicle-wrapper");
29
+
30
+ (async () => {
31
+ await Gifsicle(path.join(__dirname, "test.gif"))
32
+ .greyscale(true)
33
+ .toFile(path.join(__dirname, "test-resized.gif"));
34
+ })();
35
+ ```
36
+
37
+ Optimize the output :
38
+
39
+ ```javascript
40
+ const Gifsicle = require("@lesjoursfr/gifsicle-wrapper");
41
+
42
+ (async () => {
43
+ await Gifsicle(path.join(__dirname, "test.gif"))
44
+ .optimize({ level: gifsicle.level.O2, lossiness: 20 })
45
+ .toFile(path.join(__dirname, "test-optimized.gif"));
46
+ })();
47
+ ```
@@ -0,0 +1,28 @@
1
+ import { Gifsicle } from "../gifsicle.js";
2
+
3
+ /**
4
+ * Convert to 8-bit greyscale.
5
+ *
6
+ * @param {Boolean} [greyscale=true]
7
+ * @returns {Gifsicle}
8
+ * @throws {TypeError} Invalid parameters
9
+ */
10
+ export function greyscale(this: Gifsicle, greyscale: boolean | undefined): Gifsicle {
11
+ if (greyscale !== undefined) {
12
+ this.options.greyscale = greyscale;
13
+ } else {
14
+ this.options.greyscale = true;
15
+ }
16
+ return this;
17
+ }
18
+
19
+ /**
20
+ * Alternative spelling of `greyscale`.
21
+ *
22
+ * @param {Boolean} [grayscale=true]
23
+ * @returns {Gifsicle}
24
+ * @throws {TypeError} Invalid parameters
25
+ */
26
+ export function grayscale(this: Gifsicle, grayscale: boolean | undefined) {
27
+ return this.greyscale(grayscale);
28
+ }
@@ -0,0 +1,14 @@
1
+ import { readFileSync } from "fs";
2
+ import { isGif } from "../toolbox/is-gif.js";
3
+
4
+ export function readFile(input: string | Buffer): Buffer {
5
+ if (typeof input === "string") {
6
+ input = readFileSync(input);
7
+ }
8
+
9
+ if (!isGif(input)) {
10
+ throw new TypeError("Expected 'input' to be a gif file");
11
+ }
12
+
13
+ return input;
14
+ }
@@ -0,0 +1,51 @@
1
+ import { Gifsicle } from "../gifsicle.js";
2
+
3
+ /**
4
+ * Optimization levels.
5
+ */
6
+ /* eslint-disable no-unused-vars */
7
+ export enum OptimizationLevel {
8
+ O1 = "O1",
9
+ O2 = "O2",
10
+ O3 = "O3",
11
+ }
12
+ /* eslint-enable no-unused-vars */
13
+
14
+ /**
15
+ * Optimization options.
16
+ */
17
+ export type OptimizeOptions = {
18
+ level?: OptimizationLevel;
19
+ lossiness?: number;
20
+ };
21
+
22
+ /**
23
+ * Optimize the gif.
24
+ *
25
+ * @param {Object} [options]
26
+ * @param {OptimizationLevel} [options.level=OptimizationLevel.O1] - the optimization level.
27
+ * @param {Number} [options.lossiness=20] - the lossiness value to shrink the number of colors [0,200].
28
+ * @returns {Gifsicle}
29
+ * @throws {TypeError} Invalid parameters
30
+ */
31
+ export function optimize(this: Gifsicle, options: OptimizeOptions | undefined): Gifsicle {
32
+ // Default options
33
+ this.options.optimize = { level: OptimizationLevel.O1, lossiness: 20 };
34
+
35
+ // Process parameters
36
+ if (options !== undefined) {
37
+ // Level
38
+ if (options.level !== undefined) {
39
+ this.options.optimize.level = options.level;
40
+ }
41
+ // Lossiness
42
+ if (options.lossiness !== undefined) {
43
+ if (Number.isInteger(options.lossiness) && options.lossiness > 0 && options.lossiness < 200) {
44
+ this.options.optimize.lossiness = options.lossiness;
45
+ } else {
46
+ throw new TypeError("Expected 'lossiness' to be an integer in the range [0,200]");
47
+ }
48
+ }
49
+ }
50
+ return this;
51
+ }
@@ -0,0 +1,62 @@
1
+ import { execa } from "execa";
2
+ import { writeFileSync } from "fs";
3
+ import { Gifsicle, GifsicleInternalOptions } from "../gifsicle.js";
4
+ import { gifsicleWrapper } from "../wrapper.js";
5
+ import { computeCroppingPoint } from "./resize.js";
6
+
7
+ async function processFile(input: Buffer, options: GifsicleInternalOptions) {
8
+ const args = ["--no-warnings", "--no-app-extensions"];
9
+
10
+ if (options.greyscale === true) {
11
+ args.push("--use-colormap=gray");
12
+ }
13
+
14
+ if (options.crop !== undefined) {
15
+ const { x, y } = computeCroppingPoint(input, options.crop);
16
+ args.push(`--crop=${x}, ${y}+${options.crop.width}x${options.crop.height}`);
17
+ }
18
+
19
+ if (options.resize !== undefined) {
20
+ if (options.resize.width !== undefined || options.resize.height !== undefined) {
21
+ if (options.resize.withoutEnlargement === true) {
22
+ args.push(`--resize-fit=${options.resize.width || "_"}x${options.resize.height || "_"}`);
23
+ } else {
24
+ args.push(`--resize-touch=${options.resize.width || "_"}x${options.resize.height || "_"}`);
25
+ }
26
+ }
27
+ }
28
+
29
+ if (options.optimize !== undefined) {
30
+ if (options.optimize.level !== undefined) {
31
+ args.push(`-${options.optimize.level}`);
32
+ }
33
+ if (options.optimize.lossiness !== undefined) {
34
+ args.push(`--lossy=${options.optimize.lossiness}`);
35
+ }
36
+ }
37
+
38
+ const { stdout } = await execa(gifsicleWrapper.path, args, {
39
+ encoding: null,
40
+ input,
41
+ });
42
+
43
+ return stdout;
44
+ }
45
+
46
+ /**
47
+ * Save the result in a file.
48
+ *
49
+ * @param {String} [fileOut]
50
+ */
51
+ export async function toFile(this: Gifsicle, fileOut: string) {
52
+ writeFileSync(fileOut, await processFile(this.input, this.options));
53
+ }
54
+
55
+ /**
56
+ * Get the result file as a Buffer.
57
+ *
58
+ * @returns {Buffer}
59
+ */
60
+ export async function toBuffer(this: Gifsicle) {
61
+ return processFile(this.input, this.options);
62
+ }
@@ -0,0 +1,182 @@
1
+ import sizeOf from "image-size";
2
+ import { Gifsicle } from "../gifsicle.js";
3
+
4
+ /**
5
+ * Reduction kernels.
6
+ */
7
+ /* eslint-disable no-unused-vars */
8
+ export enum ReductionKernel {
9
+ sample = "sample",
10
+ mix = "mix",
11
+ catrom = "catrom",
12
+ mitchell = "mitchell",
13
+ lanczos2 = "lanczos2",
14
+ lanczos3 = "lanczos3",
15
+ }
16
+ /* eslint-enable no-unused-vars */
17
+
18
+ /**
19
+ * Position modes for cropping.
20
+ */
21
+ /* eslint-disable no-unused-vars */
22
+ export enum CroppingPosition {
23
+ center = "center",
24
+ top = "top",
25
+ right = "right",
26
+ bottom = "bottom",
27
+ left = "left",
28
+ topRight = "topRight",
29
+ bottomRight = "bottomRight",
30
+ bottomLeft = "bottomLeft",
31
+ topLeft = "topLeft",
32
+ }
33
+ /* eslint-enable no-unused-vars */
34
+
35
+ /**
36
+ * Resize options.
37
+ */
38
+ export type ResizeOptions = {
39
+ kernel: ReductionKernel | undefined;
40
+ withoutEnlargement: boolean | undefined;
41
+ };
42
+
43
+ /**
44
+ * Cropping options.
45
+ */
46
+ export type CroppingOptions = {
47
+ position: CroppingPosition | undefined;
48
+ };
49
+
50
+ /**
51
+ * Resize image to `width`, `height` or `width x height`.
52
+ *
53
+ * @param {Number} [width] - pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
54
+ * @param {Number} [height] - pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
55
+ * @param {Object} [options]
56
+ * @param {ReductionKernel} [options.kernel=ReductionKernel.lanczos3] - the kernel to use for image reduction.
57
+ * @param {Boolean} [options.withoutEnlargement=false] - do not enlarge if the width *or* height are already less than the specified dimensions, equivalent to GraphicsMagick's `>` geometry option. *
58
+ * @returns {Gifsicle}
59
+ * @throws {TypeError} Invalid parameters
60
+ */
61
+ export function resize(
62
+ this: Gifsicle,
63
+ width: number | undefined,
64
+ height: number | undefined,
65
+ options: ResizeOptions | undefined
66
+ ): Gifsicle {
67
+ // Default options
68
+ this.options.resize = { kernel: ReductionKernel.lanczos3, withoutEnlargement: false };
69
+
70
+ // Process parameters
71
+ if (width !== undefined) {
72
+ if (Number.isInteger(width) && width > 0) {
73
+ this.options.resize.width = width;
74
+ } else {
75
+ throw new TypeError("Expected 'width' to be a positive integer");
76
+ }
77
+ }
78
+ if (height !== undefined) {
79
+ if (Number.isInteger(height) && height > 0) {
80
+ this.options.resize.height = height;
81
+ } else {
82
+ throw new TypeError("Expected 'height' to be a positive integer");
83
+ }
84
+ }
85
+ if (options !== undefined) {
86
+ // Kernel
87
+ if (options.kernel !== undefined) {
88
+ this.options.resize.kernel = options.kernel;
89
+ }
90
+ // Without enlargement
91
+ if (options.withoutEnlargement !== undefined) {
92
+ this.options.resize.withoutEnlargement = options.withoutEnlargement;
93
+ }
94
+ }
95
+ return this;
96
+ }
97
+
98
+ /**
99
+ * Crop the image to `width x height`.
100
+ *
101
+ * @param {number} [width] - pixels wide the resultant image should be.
102
+ * @param {number} [height] - pixels high the resultant image should be.
103
+ * @param {Object} [options]
104
+ * @param {CroppingPosition} [options.position=CroppingPosition.center] - position of the cropping rectangle.
105
+ * @returns {Gifsicle}
106
+ * @throws {TypeError} Invalid parameters
107
+ */
108
+ export function crop(this: Gifsicle, width: number, height: number, options: CroppingOptions | undefined): Gifsicle {
109
+ // Default options
110
+ this.options.crop = { width: 0, height: 0, position: CroppingPosition.center };
111
+
112
+ // Process parameters
113
+ if (Number.isInteger(width) && width > 0) {
114
+ this.options.crop.width = width;
115
+ } else {
116
+ throw new TypeError("Expected 'width' to be a positive integer");
117
+ }
118
+ if (Number.isInteger(height) && height > 0) {
119
+ this.options.crop.height = height;
120
+ } else {
121
+ throw new TypeError("Expected 'height' to be a positive integer");
122
+ }
123
+ if (options !== undefined) {
124
+ // Position
125
+ if (options.position !== undefined) {
126
+ this.options.crop.position = options.position;
127
+ }
128
+ }
129
+ return this;
130
+ }
131
+
132
+ export function computeCroppingPoint(
133
+ input: Buffer,
134
+ crop: { width: number; height: number; position: CroppingPosition }
135
+ ): { x: number; y: number } {
136
+ const size = sizeOf(input);
137
+ if (size.width === undefined || size.height === undefined) {
138
+ throw new Error("Can't compute the image size");
139
+ }
140
+
141
+ let px = 0;
142
+ let py = 0;
143
+ switch (crop.position) {
144
+ case CroppingPosition.center:
145
+ px = Math.floor((size.width - crop.width) / 2);
146
+ py = Math.floor((size.height - crop.height) / 2);
147
+ break;
148
+ case CroppingPosition.top:
149
+ px = Math.floor((size.width - crop.width) / 2);
150
+ py = 0;
151
+ break;
152
+ case CroppingPosition.right:
153
+ px = size.width - crop.width;
154
+ py = Math.floor((size.height - crop.height) / 2);
155
+ break;
156
+ case CroppingPosition.bottom:
157
+ px = Math.floor((size.width - crop.width) / 2);
158
+ py = size.height - crop.height;
159
+ break;
160
+ case CroppingPosition.left:
161
+ px = 0;
162
+ py = Math.floor((size.height - crop.height) / 2);
163
+ break;
164
+ case CroppingPosition.topRight:
165
+ px = size.width - crop.width;
166
+ py = 0;
167
+ break;
168
+ case CroppingPosition.bottomRight:
169
+ px = size.width - crop.width;
170
+ py = size.height - crop.height;
171
+ break;
172
+ case CroppingPosition.bottomLeft:
173
+ px = 0;
174
+ py = size.height - crop.height;
175
+ break;
176
+ case CroppingPosition.topLeft:
177
+ px = 0;
178
+ py = 0;
179
+ break;
180
+ }
181
+ return { x: px, y: py };
182
+ }
@@ -0,0 +1,33 @@
1
+ import { grayscale, greyscale } from "./core/color.js";
2
+ import { readFile } from "./core/input.js";
3
+ import { OptimizeOptions, optimize } from "./core/optimize.js";
4
+ import { toBuffer, toFile } from "./core/output.js";
5
+ import { CroppingPosition, ReductionKernel, crop, resize } from "./core/resize.js";
6
+
7
+ export interface GifsicleInternalOptions {
8
+ greyscale?: boolean;
9
+ resize?: { width?: number; height?: number; kernel: ReductionKernel; withoutEnlargement: boolean };
10
+ crop?: { width: number; height: number; position: CroppingPosition };
11
+ optimize?: OptimizeOptions;
12
+ }
13
+
14
+ /**
15
+ * Export Gifsicle class.
16
+ */
17
+ export class Gifsicle {
18
+ options: GifsicleInternalOptions;
19
+ input: Buffer;
20
+
21
+ constructor(input: string | Buffer) {
22
+ this.input = readFile(input);
23
+ this.options = {};
24
+ }
25
+
26
+ public greyscale = greyscale;
27
+ public grayscale = grayscale;
28
+ public resize = resize;
29
+ public crop = crop;
30
+ public optimize = optimize;
31
+ public toFile = toFile;
32
+ public toBuffer = toBuffer;
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { OptimizationLevel } from "./core/optimize.js";
2
+ import { CroppingPosition, ReductionKernel } from "./core/resize.js";
3
+ import { Gifsicle } from "./gifsicle.js";
4
+
5
+ function gifsicle(input: string | Buffer): Gifsicle {
6
+ return new Gifsicle(input);
7
+ }
8
+
9
+ gifsicle.kernel = ReductionKernel;
10
+ gifsicle.position = CroppingPosition;
11
+ gifsicle.level = OptimizationLevel;
12
+
13
+ export default gifsicle;
package/src/install.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { execa } from "execa";
2
+ import { mkdir, rm } from "fs/promises";
3
+ import process from "process";
4
+ import { x as extract } from "tar";
5
+ import { temporaryFile } from "tempy";
6
+ import { gifsicleSourcePath, gifsicleWrapper } from "./wrapper.js";
7
+
8
+ async function buildFromSource(file: string, cmd: Array<string>): Promise<void> {
9
+ const temporary = temporaryFile();
10
+ console.log(`use the temporary folder : ${temporary}`);
11
+ await mkdir(temporary, { recursive: true });
12
+
13
+ await extract({ file: file, cwd: temporary, strip: 1 });
14
+
15
+ for (const x of cmd) {
16
+ await execa(x, { cwd: temporary, shell: true });
17
+ }
18
+
19
+ await rm(temporary, { recursive: true });
20
+ }
21
+
22
+ (async () => {
23
+ try {
24
+ await gifsicleWrapper.run(["--version"]);
25
+ console.log("gifsicle pre-build test passed successfully");
26
+ } catch (error) {
27
+ if (error instanceof Error) {
28
+ console.warn(error.message);
29
+ }
30
+ console.warn("gifsicle pre-build test failed");
31
+ console.info("compiling from source");
32
+
33
+ try {
34
+ const source = gifsicleSourcePath;
35
+ const destination = gifsicleWrapper.dest;
36
+ await buildFromSource(source, [
37
+ "autoreconf -ivf",
38
+ `./configure --disable-gifview --disable-gifdiff --prefix="${destination}" --bindir="${destination}"`,
39
+ "make install",
40
+ ]);
41
+
42
+ console.log("gifsicle built successfully");
43
+ } catch (error) {
44
+ if (error instanceof Error) {
45
+ console.error(error.stack);
46
+ }
47
+
48
+ process.exit(1);
49
+ }
50
+ }
51
+ })();
@@ -0,0 +1,9 @@
1
+ // Based on isGif function from https://github.com/sindresorhus/is-gif
2
+ // https://github.com/sindresorhus/is-gif/blob/main/index.js
3
+ export function isGif(buffer: Buffer) {
4
+ if (!buffer || buffer.length < 3) {
5
+ return false;
6
+ }
7
+
8
+ return buffer[0] === 0x47 && buffer[1] === 0x49 && buffer[2] === 0x46;
9
+ }
package/src/wrapper.ts ADDED
@@ -0,0 +1,16 @@
1
+ import BinWrapper from "@lesjoursfr/bin-wrapper";
2
+ import { platform } from "process";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const version = "1.94";
6
+ const base = `https://raw.githubusercontent.com/lesjoursfr/gifsicle-wrapper/main/vendor/v${version}`;
7
+
8
+ export const gifsicleWrapper = new BinWrapper({ strip: 0 });
9
+ gifsicleWrapper.addSrc(`${base}/linux/x64/gifsicle.tar.gz`, "linux", "x64");
10
+ gifsicleWrapper.setDest(fileURLToPath(new URL("../vendor", import.meta.url)));
11
+ gifsicleWrapper.setUse(platform === "win32" ? "gifsicle.exe" : "gifsicle");
12
+ gifsicleWrapper.setVersion(`>=${version}`);
13
+
14
+ export const gifsicleSourcePath = fileURLToPath(
15
+ new URL(`../vendor/v${version}/source/gifsicle.tar.gz`, import.meta.url)
16
+ );