mirror of
https://github.com/lovell/sharp.git
synced 2026-02-04 05:36:18 +01:00
Remove previously-deprecated properties from API
This commit is contained in:
@@ -11,8 +11,9 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/starlight": "^0.36.2",
|
"@astrojs/starlight": "^0.37.1",
|
||||||
"astro": "^5.15.3",
|
"astro": "^5.16.6",
|
||||||
"starlight-auto-sidebar": "^0.1.3"
|
"jsdoc-to-markdown": "^9.1.3",
|
||||||
|
"starlight-auto-sidebar": "^0.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ inputStream
|
|||||||
|
|
||||||
|
|
||||||
## sharpen
|
## sharpen
|
||||||
> sharpen([options], [flat], [jagged]) ⇒ <code>Sharp</code>
|
> sharpen([options]) ⇒ <code>Sharp</code>
|
||||||
|
|
||||||
Sharpen the image.
|
Sharpen the image.
|
||||||
|
|
||||||
@@ -189,15 +189,13 @@ See [libvips sharpen](https://www.libvips.org/API/current/method.Image.sharpen.h
|
|||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [options] | <code>Object</code> \| <code>number</code> | | if present, is an Object with attributes |
|
| [options] | <code>Object</code> | | if present, is an Object with attributes |
|
||||||
| [options.sigma] | <code>number</code> | | the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10 |
|
| [options.sigma] | <code>number</code> | | the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10 |
|
||||||
| [options.m1] | <code>number</code> | <code>1.0</code> | the level of sharpening to apply to "flat" areas, between 0 and 1000000 |
|
| [options.m1] | <code>number</code> | <code>1.0</code> | the level of sharpening to apply to "flat" areas, between 0 and 1000000 |
|
||||||
| [options.m2] | <code>number</code> | <code>2.0</code> | the level of sharpening to apply to "jagged" areas, between 0 and 1000000 |
|
| [options.m2] | <code>number</code> | <code>2.0</code> | the level of sharpening to apply to "jagged" areas, between 0 and 1000000 |
|
||||||
| [options.x1] | <code>number</code> | <code>2.0</code> | threshold between "flat" and "jagged", between 0 and 1000000 |
|
| [options.x1] | <code>number</code> | <code>2.0</code> | threshold between "flat" and "jagged", between 0 and 1000000 |
|
||||||
| [options.y2] | <code>number</code> | <code>10.0</code> | maximum amount of brightening, between 0 and 1000000 |
|
| [options.y2] | <code>number</code> | <code>10.0</code> | maximum amount of brightening, between 0 and 1000000 |
|
||||||
| [options.y3] | <code>number</code> | <code>20.0</code> | maximum amount of darkening, between 0 and 1000000 |
|
| [options.y3] | <code>number</code> | <code>20.0</code> | maximum amount of darkening, between 0 and 1000000 |
|
||||||
| [flat] | <code>number</code> | | (deprecated) see `options.m1`. |
|
|
||||||
| [jagged] | <code>number</code> | | (deprecated) see `options.m2`. |
|
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
```js
|
```js
|
||||||
@@ -360,8 +358,6 @@ with all white pixel values made fully transparent.
|
|||||||
|
|
||||||
Existing alpha channel values for non-white pixels remain unchanged.
|
Existing alpha channel values for non-white pixels remain unchanged.
|
||||||
|
|
||||||
This feature is experimental and the API may change.
|
|
||||||
|
|
||||||
|
|
||||||
**Since**: 0.32.1
|
**Since**: 0.32.1
|
||||||
**Example**
|
**Example**
|
||||||
|
|||||||
@@ -740,8 +740,7 @@ Use these AVIF options for output image.
|
|||||||
AVIF image sequences are not supported.
|
AVIF image sequences are not supported.
|
||||||
Prebuilt binaries support a bitdepth of 8 only.
|
Prebuilt binaries support a bitdepth of 8 only.
|
||||||
|
|
||||||
This feature is experimental on the Windows ARM64 platform
|
When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
|
||||||
and requires a CPU with ARM64v8.4 or later.
|
|
||||||
|
|
||||||
|
|
||||||
**Throws**:
|
**Throws**:
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ slug: changelog/v0.35.0
|
|||||||
* Breaking: Remove `install` script from `package.json` file.
|
* Breaking: Remove `install` script from `package.json` file.
|
||||||
Compiling from source is now opt-in via the `build` script.
|
Compiling from source is now opt-in via the `build` script.
|
||||||
|
|
||||||
|
* Breaking: Remove deprecated `failOnError` constructor property.
|
||||||
|
|
||||||
|
* Breaking: Remove deprecated `paletteBitDepth` from `metadata` response.
|
||||||
|
|
||||||
|
* Breaking: Remove deprecated properties from `sharpen` operation.
|
||||||
|
|
||||||
* Upgrade to libvips v8.18.0 for upstream bug fixes.
|
* Upgrade to libvips v8.18.0 for upstream bug fixes.
|
||||||
|
|
||||||
* Add `withGainMap` to process HDR JPEG images with embedded gain maps.
|
* Add `withGainMap` to process HDR JPEG images with embedded gain maps.
|
||||||
|
|||||||
32
lib/index.d.ts
vendored
32
lib/index.d.ts
vendored
@@ -259,7 +259,6 @@ declare namespace sharp {
|
|||||||
* Set the pipeline colourspace.
|
* Set the pipeline colourspace.
|
||||||
* The input image will be converted to the provided colourspace at the start of the pipeline.
|
* The input image will be converted to the provided colourspace at the start of the pipeline.
|
||||||
* All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
|
* All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
|
||||||
* This feature is experimental and has not yet been fully-tested with all operations.
|
|
||||||
*
|
*
|
||||||
* @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
|
* @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
|
||||||
* @throws {Error} Invalid parameters
|
* @throws {Error} Invalid parameters
|
||||||
@@ -470,21 +469,6 @@ declare namespace sharp {
|
|||||||
*/
|
*/
|
||||||
sharpen(options?: SharpenOptions): Sharp;
|
sharpen(options?: SharpenOptions): Sharp;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sharpen the image.
|
|
||||||
* When used without parameters, performs a fast, mild sharpen of the output image.
|
|
||||||
* When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
|
|
||||||
* Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
|
|
||||||
* @param sigma the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
|
|
||||||
* @param flat the level of sharpening to apply to "flat" areas. (optional, default 1.0)
|
|
||||||
* @param jagged the level of sharpening to apply to "jagged" areas. (optional, default 2.0)
|
|
||||||
* @throws {Error} Invalid parameters
|
|
||||||
* @returns A sharp instance that can be used to chain operations
|
|
||||||
*
|
|
||||||
* @deprecated Use the object parameter `sharpen({sigma, m1, m2, x1, y2, y3})` instead
|
|
||||||
*/
|
|
||||||
sharpen(sigma?: number, flat?: number, jagged?: number): Sharp;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply median filter. When used without parameters the default window is 3x3.
|
* Apply median filter. When used without parameters the default window is 3x3.
|
||||||
* @param size square mask size: size x size (optional, default 3)
|
* @param size square mask size: size x size (optional, default 3)
|
||||||
@@ -910,7 +894,7 @@ declare namespace sharp {
|
|||||||
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
|
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
|
||||||
* - sharp.strategy: cover only, dynamically crop using either the entropy or attention strategy. Some of these values are based on the object-position CSS property.
|
* - sharp.strategy: cover only, dynamically crop using either the entropy or attention strategy. Some of these values are based on the object-position CSS property.
|
||||||
*
|
*
|
||||||
* The experimental strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
|
* The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
|
||||||
* discarding the edge with the lowest score based on the selected strategy.
|
* discarding the edge with the lowest score based on the selected strategy.
|
||||||
* - entropy: focus on the region with the highest Shannon entropy.
|
* - entropy: focus on the region with the highest Shannon entropy.
|
||||||
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
||||||
@@ -999,14 +983,6 @@ declare namespace sharp {
|
|||||||
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
|
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
|
||||||
*/
|
*/
|
||||||
failOn?: FailOnOptions | undefined;
|
failOn?: FailOnOptions | undefined;
|
||||||
/**
|
|
||||||
* By default halt processing and raise an error when loading invalid images.
|
|
||||||
* Set this flag to false if you'd rather apply a "best effort" to decode images,
|
|
||||||
* even if the data is corrupt or invalid. (optional, default true)
|
|
||||||
*
|
|
||||||
* @deprecated Use `failOn` instead
|
|
||||||
*/
|
|
||||||
failOnError?: boolean | undefined;
|
|
||||||
/**
|
/**
|
||||||
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
||||||
* Assumes image dimensions contained in the input metadata can be trusted.
|
* Assumes image dimensions contained in the input metadata can be trusted.
|
||||||
@@ -1308,11 +1284,11 @@ declare namespace sharp {
|
|||||||
channels: ChannelStats[];
|
channels: ChannelStats[];
|
||||||
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
|
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
|
||||||
isOpaque: boolean;
|
isOpaque: boolean;
|
||||||
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any (experimental) */
|
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
|
||||||
entropy: number;
|
entropy: number;
|
||||||
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any (experimental) */
|
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any */
|
||||||
sharpness: number;
|
sharpness: number;
|
||||||
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram (experimental) */
|
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram */
|
||||||
dominant: { r: number; g: number; b: number };
|
dominant: { r: number; g: number; b: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
lib/input.js
10
lib/input.js
@@ -30,7 +30,7 @@ const inputStreamParameters = [
|
|||||||
// Format-specific
|
// Format-specific
|
||||||
'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',
|
'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',
|
||||||
// Deprecated
|
// Deprecated
|
||||||
'failOnError', 'openSlideLevel', 'pdfBackground', 'tiffSubifd'
|
'openSlideLevel', 'pdfBackground', 'tiffSubifd'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,14 +106,6 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|||||||
}`);
|
}`);
|
||||||
}
|
}
|
||||||
if (is.object(inputOptions)) {
|
if (is.object(inputOptions)) {
|
||||||
// Deprecated: failOnError
|
|
||||||
if (is.defined(inputOptions.failOnError)) {
|
|
||||||
if (is.bool(inputOptions.failOnError)) {
|
|
||||||
inputDescriptor.failOn = inputOptions.failOnError ? 'warning' : 'none';
|
|
||||||
} else {
|
|
||||||
throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// failOn
|
// failOn
|
||||||
if (is.defined(inputOptions.failOn)) {
|
if (is.defined(inputOptions.failOn)) {
|
||||||
if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {
|
if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {
|
||||||
|
|||||||
@@ -259,45 +259,18 @@ function affine (matrix, options) {
|
|||||||
* })
|
* })
|
||||||
* .toBuffer();
|
* .toBuffer();
|
||||||
*
|
*
|
||||||
* @param {Object|number} [options] - if present, is an Object with attributes
|
* @param {Object} [options] - if present, is an Object with attributes
|
||||||
* @param {number} [options.sigma] - the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10
|
* @param {number} [options.sigma] - the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10
|
||||||
* @param {number} [options.m1=1.0] - the level of sharpening to apply to "flat" areas, between 0 and 1000000
|
* @param {number} [options.m1=1.0] - the level of sharpening to apply to "flat" areas, between 0 and 1000000
|
||||||
* @param {number} [options.m2=2.0] - the level of sharpening to apply to "jagged" areas, between 0 and 1000000
|
* @param {number} [options.m2=2.0] - the level of sharpening to apply to "jagged" areas, between 0 and 1000000
|
||||||
* @param {number} [options.x1=2.0] - threshold between "flat" and "jagged", between 0 and 1000000
|
* @param {number} [options.x1=2.0] - threshold between "flat" and "jagged", between 0 and 1000000
|
||||||
* @param {number} [options.y2=10.0] - maximum amount of brightening, between 0 and 1000000
|
* @param {number} [options.y2=10.0] - maximum amount of brightening, between 0 and 1000000
|
||||||
* @param {number} [options.y3=20.0] - maximum amount of darkening, between 0 and 1000000
|
* @param {number} [options.y3=20.0] - maximum amount of darkening, between 0 and 1000000
|
||||||
* @param {number} [flat] - (deprecated) see `options.m1`.
|
|
||||||
* @param {number} [jagged] - (deprecated) see `options.m2`.
|
|
||||||
* @returns {Sharp}
|
* @returns {Sharp}
|
||||||
* @throws {Error} Invalid parameters
|
* @throws {Error} Invalid parameters
|
||||||
*/
|
*/
|
||||||
function sharpen (options, flat, jagged) {
|
function sharpen (options) {
|
||||||
if (!is.defined(options)) {
|
if (is.plainObject(options)) {
|
||||||
// No arguments: default to mild sharpen
|
|
||||||
this.options.sharpenSigma = -1;
|
|
||||||
} else if (is.bool(options)) {
|
|
||||||
// Deprecated boolean argument: apply mild sharpen?
|
|
||||||
this.options.sharpenSigma = options ? -1 : 0;
|
|
||||||
} else if (is.number(options) && is.inRange(options, 0.01, 10000)) {
|
|
||||||
// Deprecated numeric argument: specific sigma
|
|
||||||
this.options.sharpenSigma = options;
|
|
||||||
// Deprecated control over flat areas
|
|
||||||
if (is.defined(flat)) {
|
|
||||||
if (is.number(flat) && is.inRange(flat, 0, 10000)) {
|
|
||||||
this.options.sharpenM1 = flat;
|
|
||||||
} else {
|
|
||||||
throw is.invalidParameterError('flat', 'number between 0 and 10000', flat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Deprecated control over jagged areas
|
|
||||||
if (is.defined(jagged)) {
|
|
||||||
if (is.number(jagged) && is.inRange(jagged, 0, 10000)) {
|
|
||||||
this.options.sharpenM2 = jagged;
|
|
||||||
} else {
|
|
||||||
throw is.invalidParameterError('jagged', 'number between 0 and 10000', jagged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (is.plainObject(options)) {
|
|
||||||
if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {
|
if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {
|
||||||
this.options.sharpenSigma = options.sigma;
|
this.options.sharpenSigma = options.sigma;
|
||||||
} else {
|
} else {
|
||||||
@@ -339,7 +312,7 @@ function sharpen (options, flat, jagged) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw is.invalidParameterError('sigma', 'number between 0.01 and 10000', options);
|
this.options.sharpenSigma = -1;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -510,8 +483,6 @@ function flatten (options) {
|
|||||||
*
|
*
|
||||||
* Existing alpha channel values for non-white pixels remain unchanged.
|
* Existing alpha channel values for non-white pixels remain unchanged.
|
||||||
*
|
*
|
||||||
* This feature is experimental and the API may change.
|
|
||||||
*
|
|
||||||
* @since 0.32.1
|
* @since 0.32.1
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -1151,8 +1151,7 @@ function tiff (options) {
|
|||||||
* AVIF image sequences are not supported.
|
* AVIF image sequences are not supported.
|
||||||
* Prebuilt binaries support a bitdepth of 8 only.
|
* Prebuilt binaries support a bitdepth of 8 only.
|
||||||
*
|
*
|
||||||
* This feature is experimental on the Windows ARM64 platform
|
* When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
|
||||||
* and requires a CPU with ARM64v8.4 or later.
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const data = await sharp(input)
|
* const data = await sharp(input)
|
||||||
|
|||||||
@@ -182,7 +182,6 @@
|
|||||||
"exif-reader": "^2.0.3",
|
"exif-reader": "^2.0.3",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"icc": "^3.0.0",
|
"icc": "^3.0.0",
|
||||||
"jsdoc-to-markdown": "^9.1.3",
|
|
||||||
"node-addon-api": "^8.5.0",
|
"node-addon-api": "^8.5.0",
|
||||||
"node-gyp": "^12.1.0",
|
"node-gyp": "^12.1.0",
|
||||||
"tar-fs": "^3.1.1",
|
"tar-fs": "^3.1.1",
|
||||||
|
|||||||
@@ -190,10 +190,6 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|||||||
info.Set("isPalette", baton->isPalette);
|
info.Set("isPalette", baton->isPalette);
|
||||||
if (baton->bitsPerSample > 0) {
|
if (baton->bitsPerSample > 0) {
|
||||||
info.Set("bitsPerSample", baton->bitsPerSample);
|
info.Set("bitsPerSample", baton->bitsPerSample);
|
||||||
if (baton->isPalette) {
|
|
||||||
// Deprecated, remove with libvips 8.17.0
|
|
||||||
info.Set("paletteBitDepth", baton->bitsPerSample);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (baton->pages > 0) {
|
if (baton->pages > 0) {
|
||||||
info.Set("pages", baton->pages);
|
info.Set("pages", baton->pages);
|
||||||
|
|||||||
@@ -54,23 +54,6 @@ describe('failOn', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('deprecated failOnError', () => {
|
|
||||||
assert.doesNotThrow(
|
|
||||||
() => sharp({ failOnError: true })
|
|
||||||
);
|
|
||||||
assert.doesNotThrow(
|
|
||||||
() => sharp({ failOnError: false })
|
|
||||||
);
|
|
||||||
assert.throws(
|
|
||||||
() => sharp({ failOnError: 'zoinks' }),
|
|
||||||
/Expected boolean for failOnError but received zoinks of type string/
|
|
||||||
);
|
|
||||||
assert.throws(
|
|
||||||
() => sharp({ failOnError: 1 }),
|
|
||||||
/Expected boolean for failOnError but received 1 of type number/
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns errors to callback for truncated JPEG', (_t, done) => {
|
it('returns errors to callback for truncated JPEG', (_t, done) => {
|
||||||
sharp(fixtures.inputJpgTruncated, { failOn: 'truncated' }).toBuffer((err, data, info) => {
|
sharp(fixtures.inputJpgTruncated, { failOn: 'truncated' }).toBuffer((err, data, info) => {
|
||||||
assert.ok(err.message.includes('VipsJpeg: premature end of'), err);
|
assert.ok(err.message.includes('VipsJpeg: premature end of'), err);
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ describe('PNG', () => {
|
|||||||
isProgressive: false,
|
isProgressive: false,
|
||||||
isPalette: true,
|
isPalette: true,
|
||||||
bitsPerSample: 8,
|
bitsPerSample: 8,
|
||||||
paletteBitDepth: 8,
|
|
||||||
hasProfile: false,
|
hasProfile: false,
|
||||||
hasAlpha: false
|
hasAlpha: false
|
||||||
});
|
});
|
||||||
@@ -226,11 +225,10 @@ describe('PNG', () => {
|
|||||||
.png({ colours: 2, palette: false })
|
.png({ colours: 2, palette: false })
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
const { channels, isPalette, bitsPerSample, paletteBitDepth, space } = await sharp(data).metadata();
|
const { channels, isPalette, bitsPerSample, space } = await sharp(data).metadata();
|
||||||
assert.strictEqual(channels, 1);
|
assert.strictEqual(channels, 1);
|
||||||
assert.strictEqual(isPalette, false);
|
assert.strictEqual(isPalette, false);
|
||||||
assert.strictEqual(bitsPerSample, 1);
|
assert.strictEqual(bitsPerSample, 1);
|
||||||
assert.strictEqual(paletteBitDepth, undefined);
|
|
||||||
assert.strictEqual(space, 'b-w');
|
assert.strictEqual(space, 'b-w');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -94,24 +94,6 @@ describe('Sharpen', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invalid sigma', () => {
|
|
||||||
assert.throws(() => {
|
|
||||||
sharp(fixtures.inputJpg).sharpen(-1.5);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('invalid flat', () => {
|
|
||||||
assert.throws(() => {
|
|
||||||
sharp(fixtures.inputJpg).sharpen(1, -1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('invalid jagged', () => {
|
|
||||||
assert.throws(() => {
|
|
||||||
sharp(fixtures.inputJpg).sharpen(1, 1, -1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('invalid options.sigma', () => assert.throws(
|
it('invalid options.sigma', () => assert.throws(
|
||||||
() => sharp().sharpen({ sigma: -1 }),
|
() => sharp().sharpen({ sigma: -1 }),
|
||||||
/Expected number between 0\.000001 and 10 for options\.sigma but received -1 of type number/
|
/Expected number between 0\.000001 and 10 for options\.sigma but received -1 of type number/
|
||||||
@@ -144,24 +126,23 @@ describe('Sharpen', () => {
|
|||||||
|
|
||||||
it('sharpened image is larger than non-sharpened', (_t, done) => {
|
it('sharpened image is larger than non-sharpened', (_t, done) => {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.resize(320, 240)
|
.resize(32, 24)
|
||||||
.sharpen(false)
|
|
||||||
.toBuffer((err, notSharpened, info) => {
|
.toBuffer((err, notSharpened, info) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, notSharpened.length > 0);
|
assert.strictEqual(true, notSharpened.length > 0);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(32, info.width);
|
||||||
assert.strictEqual(240, info.height);
|
assert.strictEqual(24, info.height);
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.resize(320, 240)
|
.resize(32, 24)
|
||||||
.sharpen(true)
|
.sharpen()
|
||||||
.toBuffer((err, sharpened, info) => {
|
.toBuffer((err, sharpened, info) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, sharpened.length > 0);
|
assert.strictEqual(true, sharpened.length > 0);
|
||||||
assert.strictEqual(true, sharpened.length > notSharpened.length);
|
assert.strictEqual(true, sharpened.length > notSharpened.length);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(32, info.width);
|
||||||
assert.strictEqual(240, info.height);
|
assert.strictEqual(24, info.height);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user