🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

sharp

Package Overview
Dependencies
Maintainers
1
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sharp - npm Package Compare versions

Comparing version
0.34.5
to
0.35.0-rc.0
+2
-2
install/build.js

@@ -13,3 +13,3 @@ /*!

log('Attempting to build from source via node-gyp');
log('Building from source');
log('See https://sharp.pixelplumbing.com/install#building-from-source');

@@ -33,3 +33,3 @@

if (useGlobalLibvips(log)) {
log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
log(`Found globally-installed libvips v${globalLibvipsVersion()}`);
}

@@ -36,0 +36,0 @@

@@ -281,2 +281,3 @@ /*!

trimLineArt: false,
trimMargin: 0,
dilateWidth: 0,

@@ -310,2 +311,3 @@ erodeWidth: 0,

streamOut: false,
typedArrayOut: false,
keepMetadata: 0,

@@ -318,2 +320,3 @@ withMetadataOrientation: -1,

withXmp: '',
withGainMap: false,
resolveWithObject: false,

@@ -354,2 +357,3 @@ loop: -1,

webpMixed: false,
webpExact: false,
gifBitdepth: 8,

@@ -382,2 +386,3 @@ gifEffort: 7,

heifBitdepth: 8,
heifTune: 'ssim',
jxlDistance: 1,

@@ -384,0 +389,0 @@ jxlDecodingTier: 0,

@@ -33,3 +33,3 @@ /*!

// Deprecated
'failOnError', 'openSlideLevel', 'pdfBackground', 'tiffSubifd'
'openSlideLevel', 'pdfBackground', 'tiffSubifd'
];

@@ -110,10 +110,2 @@

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

@@ -579,3 +571,3 @@ if (is.defined(inputOptions.failOn)) {

*
* - `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`
* - `format`: Name of decoder used to parse image e.g. `jpeg`, `png`, `webp`, `gif`, `svg`, `heif`, `tiff`
* - `size`: Total size of image in bytes, for Stream and Buffer input only

@@ -613,2 +605,3 @@ * - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)

* - `comments`: Array of keyword/text pairs representing PNG text blocks, if present.
* - `gainMap.image`: HDR gain map, if present, as compressed JPEG image.
*

@@ -615,0 +608,0 @@ * @example

@@ -262,3 +262,3 @@ /*!

*
* @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

@@ -270,34 +270,7 @@ * @param {number} [options.m1=1.0] - the level of sharpening to apply to "flat" areas, 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}
* @throws {Error} Invalid parameters
*/
function sharpen (options, flat, jagged) {
if (!is.defined(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)) {
function sharpen (options) {
if (is.plainObject(options)) {
if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {

@@ -344,3 +317,3 @@ this.options.sharpenSigma = options.sigma;

} else {
throw is.invalidParameterError('sigma', 'number between 0.01 and 10000', options);
this.options.sharpenSigma = -1;
}

@@ -516,4 +489,2 @@ return this;

*
* This feature is experimental and the API may change.
*
* @since 0.32.1

@@ -520,0 +491,0 @@ *

@@ -79,3 +79,3 @@ /*!

err = new Error('Cannot use same file for input and output');
} else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
} else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2.output.file) {
err = errJp2Save();

@@ -169,2 +169,37 @@ }

/**
* Write output to a `Uint8Array` backed by a transferable `ArrayBuffer`.
* JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
*
* Use {@link #toformat toFormat} or one of the format-specific functions such as {@link #jpeg jpeg}, {@link #png png} etc. to set the output format.
*
* If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.
*
* By default all metadata will be removed, which includes EXIF-based orientation.
* See {@link #keepexif keepExif} and similar methods for control over this.
*
* Resolves with an `Object` containing:
* - `data` is the output image as a `Uint8Array` backed by a transferable `ArrayBuffer`.
* - `info` contains properties relating to the output image such as `width` and `height`.
*
* @since v0.35.0
*
* @example
* const { data, info } = await sharp(input).toUint8Array();
*
* @example
* const { data } = await sharp(input)
* .avif()
* .toUint8Array();
* const base64String = data.toBase64();
*
* @returns {Promise<{ data: Uint8Array, info: Object }>}
*/
function toUint8Array () {
this.options.resolveWithObject = true;
this.options.typedArrayOut = true;
const stack = Error();
return this._pipeline(null, stack);
}
/**
* Keep all EXIF metadata from the input image in the output image.

@@ -325,2 +360,26 @@ *

/**
* If the input contains gain map metadata, use it to convert the main image to HDR (High Dynamic Range) before further processing.
* The input gain map is discarded.
*
* If the output is JPEG, generate and attach a new ISO 21496-1 gain map.
* JPEG output options other than `quality` are ignored.
*
* This feature is experimental and the API may change.
*
* @since 0.35.0
*
* @example
* const outputWithGainMap = await sharp(inputWithGainMap)
* .withGainMap()
* .toBuffer();
*
* @returns {Sharp}
*/
function withGainMap() {
this.options.withGainMap = true;
this.options.colourspace = 'scrgb';
return this;
}
/**
* Keep XMP metadata from the input image in the output image.

@@ -696,2 +755,3 @@ *

* @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)
* @param {boolean} [options.exact=false] - preserve the colour data in transparent pixels
* @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format

@@ -749,2 +809,5 @@ * @returns {Sharp}

}
if (is.defined(options.exact)) {
this._setBooleanOption('webpExact', options.exact);
}
}

@@ -895,3 +958,3 @@ trySetAnimationOptions(options, this.options);

/* node:coverage ignore next 41 */
if (!this.constructor.format.jp2k.output.buffer) {
if (!this.constructor.format.jp2.output.buffer) {
throw errJp2Save();

@@ -1101,4 +1164,3 @@ }

*
* This feature is experimental on the Windows ARM64 platform
* and requires a CPU with ARM64v8.4 or later.
* When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
*

@@ -1123,2 +1185,3 @@ * @example

* @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
* @param {string} [options.tune='iq'] - tune output for a quality metric, one of 'iq' (default), 'ssim' or 'psnr'
* @returns {Sharp}

@@ -1128,3 +1191,4 @@ * @throws {Error} Invalid options

function avif (options) {
return this.heif({ ...options, compression: 'av1' });
const tune = is.object(options) && is.defined(options.tune) ? options.tune : 'iq';
return this.heif({ ...options, compression: 'av1', tune });
}

@@ -1152,2 +1216,3 @@

* @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
* @param {string} [options.tune='ssim'] - tune output for a quality metric, one of 'ssim' (default), 'psnr' or 'iq'
* @returns {Sharp}

@@ -1201,2 +1266,9 @@ * @throws {Error} Invalid options

}
if (is.defined(options.tune)) {
if (is.string(options.tune) && is.inArray(options.tune, ['iq', 'ssim', 'psnr'])) {
this.options.heifTune = options.tune;
} else {
throw is.invalidParameterError('tune', 'one of: psnr, ssim, iq', options.tune);
}
}
} else {

@@ -1649,2 +1721,3 @@ throw is.invalidParameterError('options', 'Object', options);

toBuffer,
toUint8Array,
keepExif,

@@ -1655,2 +1728,3 @@ withExif,

withIccProfile,
withGainMap,
keepXmp,

@@ -1657,0 +1731,0 @@ withXmp,

@@ -543,2 +543,10 @@ /*!

*
* @example
* // Trim image leaving (up to) a 10 pixel margin around the trimmed content.
* const output = await sharp(input)
* .trim({
* margin: 10
* })
* .toBuffer();
*
* @param {Object} [options]

@@ -548,2 +556,3 @@ * @param {string|Object} [options.background='top-left pixel'] - Background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to that of the top-left pixel.

* @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?
* @param {number} [options.margin=0] - Leave a margin around trimmed content, value is in pixels.
* @returns {Sharp}

@@ -569,2 +578,9 @@ * @throws {Error} Invalid parameters

}
if (is.defined(options.margin)) {
if (is.integer(options.margin) && options.margin >= 0) {
this.options.trimMargin = options.margin;
} else {
throw is.invalidParameterError('margin', 'positive integer', options.margin);
}
}
} else {

@@ -571,0 +587,0 @@ throw is.invalidParameterError('trim', 'object', options);

@@ -10,2 +10,3 @@ /*!

const { version } = require('../package.json');
const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');

@@ -15,4 +16,4 @@ const runtimePlatform = runtimePlatformArch();

const paths = [
`../src/build/Release/sharp-${runtimePlatform}.node`,
'../src/build/Release/sharp-wasm32.node',
`../src/build/Release/sharp-${runtimePlatform}-${version}.node`,
`../src/build/Release/sharp-wasm32-${version}.node`,
`@img/sharp-${runtimePlatform}/sharp.node`,

@@ -77,2 +78,3 @@ '@img/sharp-wasm32/sharp.node'

`- Manually install libvips >= ${minimumLibvipsVersion}`,
' See https://sharp.pixelplumbing.com/install#building-from-source',
'- Add experimental WebAssembly-based dependencies:',

@@ -79,0 +81,0 @@ ' npm install --cpu=wasm32 sharp',

@@ -27,3 +27,3 @@ /*!

format.tiff.output.alias = ['tif'];
format.jp2k.output.alias = ['j2c', 'j2k', 'jp2', 'jpx'];
format.jp2.output.alias = ['j2c', 'j2k', 'jp2', 'jpx'];

@@ -30,0 +30,0 @@ /**

{
"name": "sharp",
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
"version": "0.34.5",
"version": "0.35.0-rc.0",
"author": "Lovell Fuller <npm@lovell.info>",

@@ -92,8 +92,8 @@ "homepage": "https://sharp.pixelplumbing.com",

"Ingvar Stepanyan <me@rreverser.com>",
"Don Denton <don@happycollision.com>"
"Don Denton <don@happycollision.com>",
"Dmytro Tiapukhin <cool.gegeg@gmail.com>"
],
"scripts": {
"build": "node install/build.js",
"install": "node install/check.js || npm run build",
"clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
"clean": "rm -rf src/build/ test/fixtures/output.*",
"test": "npm run lint && npm run test-unit",

@@ -148,44 +148,43 @@ "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",

"optionalDependencies": {
"@img/sharp-darwin-arm64": "0.34.5",
"@img/sharp-darwin-x64": "0.34.5",
"@img/sharp-libvips-darwin-arm64": "1.2.4",
"@img/sharp-libvips-darwin-x64": "1.2.4",
"@img/sharp-libvips-linux-arm": "1.2.4",
"@img/sharp-libvips-linux-arm64": "1.2.4",
"@img/sharp-libvips-linux-ppc64": "1.2.4",
"@img/sharp-libvips-linux-riscv64": "1.2.4",
"@img/sharp-libvips-linux-s390x": "1.2.4",
"@img/sharp-libvips-linux-x64": "1.2.4",
"@img/sharp-libvips-linuxmusl-arm64": "1.2.4",
"@img/sharp-libvips-linuxmusl-x64": "1.2.4",
"@img/sharp-linux-arm": "0.34.5",
"@img/sharp-linux-arm64": "0.34.5",
"@img/sharp-linux-ppc64": "0.34.5",
"@img/sharp-linux-riscv64": "0.34.5",
"@img/sharp-linux-s390x": "0.34.5",
"@img/sharp-linux-x64": "0.34.5",
"@img/sharp-linuxmusl-arm64": "0.34.5",
"@img/sharp-linuxmusl-x64": "0.34.5",
"@img/sharp-wasm32": "0.34.5",
"@img/sharp-win32-arm64": "0.34.5",
"@img/sharp-win32-ia32": "0.34.5",
"@img/sharp-win32-x64": "0.34.5"
"@img/sharp-darwin-arm64": "0.35.0-rc.0",
"@img/sharp-darwin-x64": "0.35.0-rc.0",
"@img/sharp-libvips-darwin-arm64": "1.3.0-rc.2",
"@img/sharp-libvips-darwin-x64": "1.3.0-rc.2",
"@img/sharp-libvips-linux-arm": "1.3.0-rc.2",
"@img/sharp-libvips-linux-arm64": "1.3.0-rc.2",
"@img/sharp-libvips-linux-ppc64": "1.3.0-rc.2",
"@img/sharp-libvips-linux-riscv64": "1.3.0-rc.2",
"@img/sharp-libvips-linux-s390x": "1.3.0-rc.2",
"@img/sharp-libvips-linux-x64": "1.3.0-rc.2",
"@img/sharp-libvips-linuxmusl-arm64": "1.3.0-rc.2",
"@img/sharp-libvips-linuxmusl-x64": "1.3.0-rc.2",
"@img/sharp-linux-arm": "0.35.0-rc.0",
"@img/sharp-linux-arm64": "0.35.0-rc.0",
"@img/sharp-linux-ppc64": "0.35.0-rc.0",
"@img/sharp-linux-riscv64": "0.35.0-rc.0",
"@img/sharp-linux-s390x": "0.35.0-rc.0",
"@img/sharp-linux-x64": "0.35.0-rc.0",
"@img/sharp-linuxmusl-arm64": "0.35.0-rc.0",
"@img/sharp-linuxmusl-x64": "0.35.0-rc.0",
"@img/sharp-wasm32": "0.35.0-rc.0",
"@img/sharp-win32-arm64": "0.35.0-rc.0",
"@img/sharp-win32-ia32": "0.35.0-rc.0",
"@img/sharp-win32-x64": "0.35.0-rc.0"
},
"devDependencies": {
"@biomejs/biome": "^2.3.4",
"@biomejs/biome": "^2.3.10",
"@cpplint/cli": "^0.1.0",
"@emnapi/runtime": "^1.7.0",
"@img/sharp-libvips-dev": "1.2.4",
"@img/sharp-libvips-dev-wasm32": "1.2.4",
"@img/sharp-libvips-win32-arm64": "1.2.4",
"@img/sharp-libvips-win32-ia32": "1.2.4",
"@img/sharp-libvips-win32-x64": "1.2.4",
"@emnapi/runtime": "^1.7.1",
"@img/sharp-libvips-dev": "1.3.0-rc.2",
"@img/sharp-libvips-dev-wasm32": "1.3.0-rc.2",
"@img/sharp-libvips-win32-arm64": "1.3.0-rc.2",
"@img/sharp-libvips-win32-ia32": "1.3.0-rc.2",
"@img/sharp-libvips-win32-x64": "1.3.0-rc.2",
"@types/node": "*",
"emnapi": "^1.7.0",
"exif-reader": "^2.0.2",
"emnapi": "^1.7.1",
"exif-reader": "^2.0.3",
"extract-zip": "^2.0.1",
"icc": "^3.0.0",
"jsdoc-to-markdown": "^9.1.3",
"node-addon-api": "^8.5.0",
"node-gyp": "^11.5.0",
"node-gyp": "^12.1.0",
"tar-fs": "^3.1.1",

@@ -196,6 +195,6 @@ "tsd": "^0.33.0"

"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
"node": ">=20.9.0"
},
"config": {
"libvips": ">=8.17.3"
"libvips": ">=8.18.0"
},

@@ -202,0 +201,0 @@ "funding": {

@@ -11,3 +11,3 @@ # sharp

that provide support for Node-API v9, including
Node.js (^18.17.0 or >= 20.3.0), Deno and Bun.
Node.js (>= 20.9.0), Deno and Bun.

@@ -14,0 +14,0 @@ Resizing an image is typically 4x-5x faster than using the

@@ -292,2 +292,3 @@ /*!

case ImageType::DCRAW: id = "dcraw"; break;
case ImageType::UHDR: id = "uhdr"; break;
case ImageType::VIPS: id = "vips"; break;

@@ -343,2 +344,5 @@ case ImageType::RAW: id = "raw"; break;

{ "VipsForeignLoadDcRawBuffer", ImageType::DCRAW },
{ "VipsForeignLoadUhdr", ImageType::UHDR },
{ "VipsForeignLoadUhdrFile", ImageType::UHDR },
{ "VipsForeignLoadUhdrBuffer", ImageType::UHDR },
{ "VipsForeignLoadVips", ImageType::VIPS },

@@ -361,2 +365,5 @@ { "VipsForeignLoadVipsFile", ImageType::VIPS },

}
if (imageType == ImageType::UHDR) {
imageType = ImageType::JPEG;
}
return imageType;

@@ -381,2 +388,5 @@ }

}
if (imageType == ImageType::UHDR) {
imageType = ImageType::JPEG;
}
return imageType;

@@ -1134,2 +1144,18 @@ }

}
/*
Does this image have a gain map?
*/
bool HasGainMap(VImage image) {
return image.get_typeof("gainmap-data") == VIPS_TYPE_BLOB;
}
/*
Removes gain map, if any.
*/
VImage RemoveGainMap(VImage image) {
VImage copy = image.copy();
copy.remove("gainmap-data");
return copy;
}
} // namespace sharp

@@ -21,5 +21,5 @@ /*!

#if (VIPS_MAJOR_VERSION < 8) || \
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 17) || \
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 17 && VIPS_MICRO_VERSION < 3)
#error "libvips version 8.17.3+ is required - please see https://sharp.pixelplumbing.com/install"
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 18) || \
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 0)
#error "libvips version 8.18.0+ is required - please see https://sharp.pixelplumbing.com/install"
#endif

@@ -177,2 +177,3 @@

DCRAW,
UHDR,
VIPS,

@@ -402,4 +403,14 @@ RAW,

/*
Does this image have a gain map?
*/
bool HasGainMap(VImage image);
/*
Removes gain map, if any.
*/
VImage RemoveGainMap(VImage image);
} // namespace sharp
#endif // SRC_COMMON_H_

@@ -144,2 +144,10 @@ /*!

}
// Gain Map
if (image.get_typeof("gainmap-data") == VIPS_TYPE_BLOB) {
size_t gainMapLength;
void const *gainMap = image.get_blob("gainmap-data", &gainMapLength);
baton->gainMap = static_cast<char *>(g_malloc(gainMapLength));
memcpy(baton->gainMap, gainMap, gainMapLength);
baton->gainMapLength = gainMapLength;
}
// PNG comments

@@ -186,6 +194,2 @@ vips_image_map(image.get_image(), readPNGComment, &baton->comments);

info.Set("bitsPerSample", baton->bitsPerSample);
if (baton->isPalette) {
// Deprecated, remove with libvips 8.17.0
info.Set("paletteBitDepth", baton->bitsPerSample);
}
}

@@ -281,2 +285,8 @@ if (baton->pages > 0) {

}
if (baton->gainMapLength > 0) {
Napi::Object gainMap = Napi::Object::New(env);
info.Set("gainMap", gainMap);
gainMap.Set("image",
Napi::Buffer<char>::NewOrCopy(env, baton->gainMap, baton->gainMapLength, sharp::FreeCallback));
}
if (baton->comments.size() > 0) {

@@ -283,0 +293,0 @@ int i = 0;

@@ -56,2 +56,4 @@ /*!

size_t tifftagPhotoshopLength;
char *gainMap;
size_t gainMapLength;
MetadataComments comments;

@@ -86,3 +88,5 @@ std::string err;

tifftagPhotoshop(nullptr),
tifftagPhotoshopLength(0) {}
tifftagPhotoshopLength(0),
gainMap(nullptr),
gainMapLength(0) {}
};

@@ -89,0 +93,0 @@

@@ -288,3 +288,3 @@ /*!

*/
VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt) {
VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt, int const margin) {
if (image.width() < 3 && image.height() < 3) {

@@ -324,9 +324,21 @@ throw VError("Image to trim must be at least 3x3 pixels");

// Combined bounding box (B)
int const leftB = std::min(left, leftA);
int const topB = std::min(top, topA);
int const widthB = std::max(left + width, leftA + widthA) - leftB;
int const heightB = std::max(top + height, topA + heightA) - topB;
int leftB = std::min(left, leftA);
int topB = std::min(top, topA);
int widthB = std::max(left + width, leftA + widthA) - leftB;
int heightB = std::max(top + height, topA + heightA) - topB;
if (margin > 0) {
leftB = std::max(0, leftB - margin);
topB = std::max(0, topB - margin);
widthB = std::min(image.width() - leftB, widthB + 2 * margin);
heightB = std::min(image.height() - topB, heightB + 2 * margin);
}
return image.extract_area(leftB, topB, widthB, heightB);
} else {
// Use alpha only
if (margin > 0) {
leftA = std::max(0, leftA - margin);
topA = std::max(0, topA - margin);
widthA = std::min(image.width() - leftA, widthA + 2 * margin);
heightA = std::min(image.height() - topA, heightA + 2 * margin);
}
return image.extract_area(leftA, topA, widthA, heightA);

@@ -337,2 +349,8 @@ }

if (width > 0 && height > 0) {
if (margin > 0) {
left = std::max(0, left - margin);
top = std::max(0, top - margin);
width = std::min(image.width() - left, width + 2 * margin);
height = std::min(image.height() - top, height + 2 * margin);
}
return image.extract_area(left, top, width, height);

@@ -339,0 +357,0 @@ }

@@ -85,3 +85,3 @@ /*!

*/
VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt);
VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt, int const margin);

@@ -88,0 +88,0 @@ /*

@@ -51,2 +51,3 @@ /*!

int pagesOut;
bool typedArrayOut;
std::vector<Composite *> composite;

@@ -105,2 +106,3 @@ std::vector<sharp::InputDescriptor *> joinChannelIn;

int trimOffsetTop;
int trimMargin;
std::vector<double> linearA;

@@ -172,2 +174,3 @@ std::vector<double> linearB;

bool webpMixed;
bool webpExact;
int gifBitdepth;

@@ -200,2 +203,3 @@ int gifEffort;

int heifBitdepth;
std::string heifTune;
double jxlDistance;

@@ -215,2 +219,3 @@ int jxlDecodingTier;

std::string withXmp;
bool withGainMap;
int timeoutSeconds;

@@ -250,2 +255,3 @@ std::vector<double> convKernel;

pagesOut(0),
typedArrayOut(false),
topOffsetPre(-1),

@@ -290,2 +296,3 @@ topOffsetPost(-1),

trimOffsetTop(0),
trimMargin(0),
linearA{},

@@ -354,2 +361,3 @@ linearB{},

webpMixed(false),
webpExact(false),
gifBitdepth(8),

@@ -382,2 +390,3 @@ gifEffort(7),

heifBitdepth(8),
heifTune("ssim"),
jxlDistance(1.0),

@@ -393,2 +402,3 @@ jxlDecodingTier(0),

withExifMerge(true),
withGainMap(false),
timeoutSeconds(0),

@@ -395,0 +405,0 @@ convKernelWidth(0),

@@ -126,2 +126,3 @@ /*!

}) {
std::string id = f == "jp2k" ? "jp2" : f;
// Input

@@ -158,7 +159,7 @@ const VipsObjectClass *oc = vips_class_find("VipsOperation", (f + "load").c_str());

Napi::Object container = Napi::Object::New(env);
container.Set("id", f);
container.Set("id", id);
container.Set("input", input);
container.Set("output", output);
// Add to set of formats
format.Set(f, container);
format.Set(id, container);
}

@@ -165,0 +166,0 @@

/*!
Copyright 2013 Lovell Fuller and others.
SPDX-License-Identifier: Apache-2.0
*/
try {
const { useGlobalLibvips } = require('../lib/libvips');
if (useGlobalLibvips() || process.env.npm_config_build_from_source) {
process.exit(1);
}
} catch (err) {
const summary = err.message.split(/\n/).slice(0, 1);
console.log(`sharp: skipping install check: ${summary}`);
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display