Socket
Socket
Sign inDemoInstall

sharp

Package Overview
Dependencies
Maintainers
1
Versions
156
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.33.0-alpha.9 to 0.33.0-alpha.10

6

lib/constructor.js

@@ -124,3 +124,3 @@ // Copyright 2013 Lovell Fuller and others.

* @param {Object} [options] - if present, is an Object with optional attributes.
* @param {string} [options.failOn='warning'] - when to abort processing of invalid pixel data, one of (in order of sensitivity): 'none' (least), 'truncated', 'error' or 'warning' (most), higher levels imply lower levels, invalid metadata will always abort.
* @param {string} [options.failOn='warning'] - When to abort processing of invalid pixel data, one of (in order of sensitivity, least to most): 'none', 'truncated', 'error', 'warning'. Higher levels imply lower levels. Invalid metadata will always abort.
* @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels

@@ -234,3 +234,4 @@ * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.

trimBackground: [],
trimThreshold: 0,
trimThreshold: -1,
trimLineArt: false,
gamma: 0,

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

tiffPyramid: false,
tiffMiniswhite: false,
tiffBitdepth: 8,

@@ -312,0 +314,0 @@ tiffTile: false,

@@ -785,2 +785,3 @@ // Copyright 2013 Lovell Fuller and others.

* @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit
* @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite
* @returns {Sharp}

@@ -823,2 +824,6 @@ * @throws {Error} Invalid options

}
// miniswhite
if (is.defined(options.miniswhite)) {
this._setBooleanOption('tiffMiniswhite', options.miniswhite);
}
// pyramid

@@ -825,0 +830,0 @@ if (is.defined(options.pyramid)) {

@@ -497,29 +497,30 @@ // Copyright 2013 Lovell Fuller and others.

*
* The `info` response Object, obtained from callback of `.toFile()` or `.toBuffer()`,
* will contain `trimOffsetLeft` and `trimOffsetTop` properties.
* The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.
*
* @example
* // Trim pixels with a colour similar to that of the top-left pixel.
* sharp(input)
* await sharp(input)
* .trim()
* .toFile(output, function(err, info) {
* ...
* });
* .toFile(output);
*
* @example
* // Trim pixels with the exact same colour as that of the top-left pixel.
* sharp(input)
* .trim(0)
* .toFile(output, function(err, info) {
* ...
* });
* await sharp(input)
* .trim({
* threshold: 0
* })
* .toFile(output);
*
* @example
* // Trim only pixels with a similar colour to red.
* sharp(input)
* .trim("#FF0000")
* .toFile(output, function(err, info) {
* ...
* });
* // Assume input is line art and trim only pixels with a similar colour to red.
* const output = await sharp(input)
* .trim({
* background: "#FF0000",
* lineArt: true
* })
* .toBuffer();
*
* @example
* // Trim all "yellow-ish" pixels, being more lenient with the higher threshold.
* sharp(input)
* const output = await sharp(input)
* .trim({

@@ -529,35 +530,31 @@ * background: "yellow",

* })
* .toFile(output, function(err, info) {
* ...
* });
* .toBuffer();
*
* @param {string|number|Object} trim - the specific background colour to trim, the threshold for doing so or an Object with both.
* @param {string|Object} [trim.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 {number} [trim.threshold=10] - the allowed difference from the above colour, a positive number.
* @param {Object} [options]
* @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 {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.
* @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
function trim (trim) {
if (!is.defined(trim)) {
this.options.trimThreshold = 10;
} else if (is.string(trim)) {
this._setBackgroundColourOption('trimBackground', trim);
this.options.trimThreshold = 10;
} else if (is.number(trim)) {
if (trim >= 0) {
this.options.trimThreshold = trim;
function trim (options) {
this.options.trimThreshold = 10;
if (is.defined(options)) {
if (is.object(options)) {
if (is.defined(options.background)) {
this._setBackgroundColourOption('trimBackground', options.background);
}
if (is.defined(options.threshold)) {
if (is.number(options.threshold) && options.threshold >= 0) {
this.options.trimThreshold = options.threshold;
} else {
throw is.invalidParameterError('threshold', 'positive number', options.threshold);
}
}
if (is.defined(options.lineArt)) {
this._setBooleanOption('trimLineArt', options.lineArt);
}
} else {
throw is.invalidParameterError('threshold', 'positive number', trim);
throw is.invalidParameterError('trim', 'object', options);
}
} else if (is.object(trim)) {
this._setBackgroundColourOption('trimBackground', trim.background);
if (!is.defined(trim.threshold)) {
this.options.trimThreshold = 10;
} else if (is.number(trim.threshold) && trim.threshold >= 0) {
this.options.trimThreshold = trim.threshold;
} else {
throw is.invalidParameterError('threshold', 'positive number', trim);
}
} else {
throw is.invalidParameterError('trim', 'string, number or object', trim);
}

@@ -564,0 +561,0 @@ if (isRotationExpected(this.options)) {

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

@@ -89,3 +89,4 @@ "homepage": "https://github.com/lovell/sharp",

"Mart Jansink <m.jansink@gmail.com>",
"Lachlan Newman <lachnewman007@gmail.com>"
"Lachlan Newman <lachnewman007@gmail.com>",
"Dennis Beatty <dennis@dcbeatty.com>"
],

@@ -143,23 +144,25 @@ "scripts": {

"optionalDependencies": {
"@img/sharp-darwin-arm64": "0.33.0-alpha.9",
"@img/sharp-darwin-x64": "0.33.0-alpha.9",
"@img/sharp-libvips-darwin-arm64": "0.0.1",
"@img/sharp-libvips-darwin-x64": "0.0.1",
"@img/sharp-libvips-linux-arm": "0.0.1",
"@img/sharp-libvips-linux-arm64": "0.0.1",
"@img/sharp-libvips-linux-x64": "0.0.1",
"@img/sharp-libvips-linuxmusl-arm64": "0.0.1",
"@img/sharp-libvips-linuxmusl-x64": "0.0.1",
"@img/sharp-linux-arm": "0.33.0-alpha.9",
"@img/sharp-linux-arm64": "0.33.0-alpha.9",
"@img/sharp-linux-x64": "0.33.0-alpha.9",
"@img/sharp-linuxmusl-arm64": "0.33.0-alpha.9",
"@img/sharp-linuxmusl-x64": "0.33.0-alpha.9",
"@img/sharp-win32-ia32": "0.33.0-alpha.9",
"@img/sharp-win32-x64": "0.33.0-alpha.9"
"@img/sharp-darwin-arm64": "0.33.0-alpha.10",
"@img/sharp-darwin-x64": "0.33.0-alpha.10",
"@img/sharp-libvips-darwin-arm64": "0.0.3",
"@img/sharp-libvips-darwin-x64": "0.0.3",
"@img/sharp-libvips-linux-arm": "0.0.3",
"@img/sharp-libvips-linux-arm64": "0.0.3",
"@img/sharp-libvips-linux-s390x": "0.0.3",
"@img/sharp-libvips-linux-x64": "0.0.3",
"@img/sharp-libvips-linuxmusl-arm64": "0.0.3",
"@img/sharp-libvips-linuxmusl-x64": "0.0.3",
"@img/sharp-linux-arm": "0.33.0-alpha.10",
"@img/sharp-linux-arm64": "0.33.0-alpha.10",
"@img/sharp-linux-s390x": "0.33.0-alpha.10",
"@img/sharp-linux-x64": "0.33.0-alpha.10",
"@img/sharp-linuxmusl-arm64": "0.33.0-alpha.10",
"@img/sharp-linuxmusl-x64": "0.33.0-alpha.10",
"@img/sharp-win32-ia32": "0.33.0-alpha.10",
"@img/sharp-win32-x64": "0.33.0-alpha.10"
},
"devDependencies": {
"@img/sharp-libvips-dev": "0.0.1",
"@img/sharp-libvips-win32-ia32": "0.0.1",
"@img/sharp-libvips-win32-x64": "0.0.1",
"@img/sharp-libvips-dev": "0.0.3",
"@img/sharp-libvips-win32-ia32": "0.0.3",
"@img/sharp-libvips-win32-x64": "0.0.3",
"@types/node": "*",

@@ -184,3 +187,3 @@ "async": "^3.2.4",

"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"libvips": ">=8.14.5"
"libvips": ">=8.15.0"
},

@@ -187,0 +190,0 @@ "funding": {

@@ -5,6 +5,10 @@ # sharp

The typical use case for this high speed Node.js module
The typical use case for this high speed Node-API module
is to convert large images in common formats to
smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions.
It can be used with all JavaScript runtimes
that provide support for Node-API v9, including
Node.js >= 18.17.0, Deno and Bun.
Resizing an image is typically 4x-5x faster than using the

@@ -20,3 +24,3 @@ quickest ImageMagick and GraphicsMagick settings

Most modern macOS, Windows and Linux systems running Node.js >= 18.17.0
Most modern macOS, Windows and Linux systems
do not require any additional install or runtime dependencies.

@@ -23,0 +27,0 @@

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc