mirror of
https://github.com/lovell/sharp.git
synced 2025-12-18 23:05:04 +01:00
Expose keepDuplicateFrames GIF output parameter
This commit is contained in:
@@ -338,6 +338,7 @@ const Sharp = function (input, options) {
|
||||
gifDither: 1,
|
||||
gifInterFrameMaxError: 0,
|
||||
gifInterPaletteMaxError: 3,
|
||||
gifKeepDuplicateFrames: false,
|
||||
gifReuse: true,
|
||||
gifProgressive: false,
|
||||
tiffQuality: 80,
|
||||
|
||||
6
lib/index.d.ts
vendored
6
lib/index.d.ts
vendored
@@ -1392,9 +1392,11 @@ declare namespace sharp {
|
||||
/** Level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most) (optional, default 1.0) */
|
||||
dither?: number | undefined;
|
||||
/** Maximum inter-frame error for transparency, between 0 (lossless) and 32 (optional, default 0) */
|
||||
interFrameMaxError?: number;
|
||||
interFrameMaxError?: number | undefined;
|
||||
/** Maximum inter-palette error for palette reuse, between 0 and 256 (optional, default 3) */
|
||||
interPaletteMaxError?: number;
|
||||
interPaletteMaxError?: number | undefined;
|
||||
/** Keep duplicate frames in the output instead of combining them (optional, default false) */
|
||||
keepDuplicateFrames?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface TiffOptions extends OutputOptions {
|
||||
|
||||
@@ -729,6 +729,7 @@ function webp (options) {
|
||||
* @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most)
|
||||
* @param {number} [options.interFrameMaxError=0] - maximum inter-frame error for transparency, between 0 (lossless) and 32
|
||||
* @param {number} [options.interPaletteMaxError=3] - maximum inter-palette error for palette reuse, between 0 and 256
|
||||
* @param {boolean} [options.keepDuplicateFrames=false] - keep duplicate frames in the output instead of combining them
|
||||
* @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation
|
||||
* @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
|
||||
* @param {boolean} [options.force=true] - force GIF output, otherwise attempt to use input format
|
||||
@@ -779,6 +780,13 @@ function gif (options) {
|
||||
throw is.invalidParameterError('interPaletteMaxError', 'number between 0.0 and 256.0', options.interPaletteMaxError);
|
||||
}
|
||||
}
|
||||
if (is.defined(options.keepDuplicateFrames)) {
|
||||
if (is.bool(options.keepDuplicateFrames)) {
|
||||
this._setBooleanOption('gifKeepDuplicateFrames', options.keepDuplicateFrames);
|
||||
} else {
|
||||
throw is.invalidParameterError('keepDuplicateFrames', 'boolean', options.keepDuplicateFrames);
|
||||
}
|
||||
}
|
||||
}
|
||||
trySetAnimationOptions(options, this.options);
|
||||
return this._updateFormatOut('gif', options);
|
||||
|
||||
Reference in New Issue
Block a user