Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

sharp

Package Overview
Dependencies
Maintainers
1
Versions
182
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.35.0-rc.5
to
0.35.0-rc.6
+1
-0
dist/composite.cjs

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

* @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor/ constructor parameters}
* @param {number|boolean} [images[].limitInputChannels=5] - @see {@link /api-constructor/ constructor parameters}
* @returns {Sharp}

@@ -130,0 +131,0 @@ * @throws {Error} Invalid parameters

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

* @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor/ constructor parameters}
* @param {number|boolean} [images[].limitInputChannels=5] - @see {@link /api-constructor/ constructor parameters}
* @returns {Sharp}

@@ -130,0 +131,0 @@ * @throws {Error} Invalid parameters

+32
-26

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

* // and finally write image data to writableStream
* const { body } = fetch('https://...');
* const { body } = await fetch('https://...');
* const readableStream = Readable.fromWeb(body);

@@ -62,2 +62,13 @@ * const transformer = sharp()

* @example
* // Web Streams API, requires Node.js >= 24.15.0
* const { Duplex } = require('node:stream');
*
* const { body } = await fetch('https://...');
* const transformer = Duplex.toWeb(
* sharp().resize(300),
* { readableType: 'bytes' }
* );
* body.pipeThrough(transformer).pipeTo(writable);
*
* @example
* // Create a blank 300x200 PNG image of semi-translucent red pixels

@@ -151,6 +162,8 @@ * sharp({

* @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, least to most): 'none', 'truncated', 'error', 'warning'. 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. Use the default 'warning' level with untrusted input.
* @param {number|boolean} [options.limitInputPixels=268402689] - 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.
* An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).
* @param {number|boolean} [options.limitInputChannels=5] - Do not process input images where the number of channels exceeds this limit. Assumes image metadata can be trusted.
* An integral Number of channels, zero or false to remove limit, true to use default limit of 5.
* @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).

@@ -386,3 +399,3 @@ * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.

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

@@ -429,18 +442,23 @@ jxlDecodingTier: 0,

* @example
* const pipeline = sharp().rotate();
* pipeline.clone().resize(800, 600).pipe(firstWritableStream);
* pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(secondWritableStream);
* readableStream.pipe(pipeline);
* // firstWritableStream receives auto-rotated, resized readableStream
* // secondWritableStream receives auto-rotated, extracted region of readableStream
*
* const pipeline = sharp().rotate();
* pipeline
* .clone()
* .resize(800, 600)
* .pipe(firstWritableStream);
* pipeline
* .clone()
* .extract({ left: 20, top: 20, width: 100, height: 100 })
* .pipe(secondWritableStream);
* readableStream.pipe(pipeline);
*
* @example
* // Create a pipeline that will download an image, resize it and format it to different files
* // Using Promises to know when the pipeline is complete
* const fs = require("node:fs");
* const got = require("got");
* const sharpStream = sharp({ failOn: 'none' });
*
* const sharpStream = sharp();
*
* const promises = [];
*
* promises.push(

@@ -452,3 +470,2 @@ * sharpStream

* );
*
* promises.push(

@@ -461,3 +478,2 @@ * sharpStream

* );
*
* promises.push(

@@ -471,16 +487,6 @@ * sharpStream

*
* // https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md
* got.stream("https://www.example.com/some-file.jpg").pipe(sharpStream);
* const res = await fetch("https://www.example.com/some-file.jpg")
* Readable.fromWeb(res.body).pipe(sharpStream);
* await Promise.all(promises);
*
* Promise.all(promises)
* .then(res => { console.log("Done!", res); })
* .catch(err => {
* console.error("Error processing files, let's clean it up", err);
* try {
* fs.unlinkSync("originalFile.jpg");
* fs.unlinkSync("optimized-500.jpg");
* fs.unlinkSync("optimized-500.webp");
* } catch (e) {}
* });
*
* @returns {Sharp}

@@ -487,0 +493,0 @@ */

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

* // and finally write image data to writableStream
* const { body } = fetch('https://...');
* const { body } = await fetch('https://...');
* const readableStream = Readable.fromWeb(body);

@@ -62,2 +62,13 @@ * const transformer = sharp()

* @example
* // Web Streams API, requires Node.js >= 24.15.0
* import { Duplex } from 'node:stream';
*
* const { body } = await fetch('https://...');
* const transformer = Duplex.toWeb(
* sharp().resize(300),
* { readableType: 'bytes' }
* );
* body.pipeThrough(transformer).pipeTo(writable);
*
* @example
* // Create a blank 300x200 PNG image of semi-translucent red pixels

@@ -151,6 +162,8 @@ * sharp({

* @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, least to most): 'none', 'truncated', 'error', 'warning'. 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. Use the default 'warning' level with untrusted input.
* @param {number|boolean} [options.limitInputPixels=268402689] - 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.
* An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).
* @param {number|boolean} [options.limitInputChannels=5] - Do not process input images where the number of channels exceeds this limit. Assumes image metadata can be trusted.
* An integral Number of channels, zero or false to remove limit, true to use default limit of 5.
* @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).

@@ -386,3 +399,3 @@ * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.

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

@@ -429,18 +442,23 @@ jxlDecodingTier: 0,

* @example
* const pipeline = sharp().rotate();
* pipeline.clone().resize(800, 600).pipe(firstWritableStream);
* pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(secondWritableStream);
* readableStream.pipe(pipeline);
* // firstWritableStream receives auto-rotated, resized readableStream
* // secondWritableStream receives auto-rotated, extracted region of readableStream
*
* const pipeline = sharp().rotate();
* pipeline
* .clone()
* .resize(800, 600)
* .pipe(firstWritableStream);
* pipeline
* .clone()
* .extract({ left: 20, top: 20, width: 100, height: 100 })
* .pipe(secondWritableStream);
* readableStream.pipe(pipeline);
*
* @example
* // Create a pipeline that will download an image, resize it and format it to different files
* // Using Promises to know when the pipeline is complete
* import fs from "node:fs";
* import got from "got";
* const sharpStream = sharp({ failOn: 'none' });
*
* const sharpStream = sharp();
*
* const promises = [];
*
* promises.push(

@@ -452,3 +470,2 @@ * sharpStream

* );
*
* promises.push(

@@ -461,3 +478,2 @@ * sharpStream

* );
*
* promises.push(

@@ -471,16 +487,6 @@ * sharpStream

*
* // https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md
* got.stream("https://www.example.com/some-file.jpg").pipe(sharpStream);
* const res = await fetch("https://www.example.com/some-file.jpg")
* Readable.fromWeb(res.body).pipe(sharpStream);
* await Promise.all(promises);
*
* Promise.all(promises)
* .then(res => { console.log("Done!", res); })
* .catch(err => {
* console.error("Error processing files, let's clean it up", err);
* try {
* fs.unlinkSync("originalFile.jpg");
* fs.unlinkSync("optimized-500.jpg");
* fs.unlinkSync("optimized-500.webp");
* } catch (e) {}
* });
*
* @returns {Sharp}

@@ -487,0 +493,0 @@ */

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

// Limits and error handling
'failOn', 'limitInputPixels', 'unlimited',
'failOn', 'limitInputPixels', 'limitInputChannels', 'unlimited',
// Format-generic

@@ -59,2 +59,3 @@ 'animated', 'autoOrient', 'density', 'ignoreIcc', 'page', 'pages', 'sequentialRead',

limitInputPixels: 0x3FFF ** 2,
limitInputChannels: 5,
ignoreIcc: false,

@@ -155,2 +156,12 @@ unlimited: false,

}
// limitInputChannels
if (is.defined(inputOptions.limitInputChannels)) {
if (is.bool(inputOptions.limitInputChannels)) {
inputDescriptor.limitInputChannels = inputOptions.limitInputChannels ? 5 : 0;
} else if (is.integer(inputOptions.limitInputChannels) && is.inRange(inputOptions.limitInputChannels, 0, Number.MAX_SAFE_INTEGER)) {
inputDescriptor.limitInputChannels = inputOptions.limitInputChannels;
} else {
throw is.invalidParameterError('limitInputChannels', 'positive integer', inputOptions.limitInputChannels);
}
}
// unlimited

@@ -157,0 +168,0 @@ if (is.defined(inputOptions.unlimited)) {

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

// Limits and error handling
'failOn', 'limitInputPixels', 'unlimited',
'failOn', 'limitInputPixels', 'limitInputChannels', 'unlimited',
// Format-generic

@@ -59,2 +59,3 @@ 'animated', 'autoOrient', 'density', 'ignoreIcc', 'page', 'pages', 'sequentialRead',

limitInputPixels: 0x3FFF ** 2,
limitInputChannels: 5,
ignoreIcc: false,

@@ -155,2 +156,12 @@ unlimited: false,

}
// limitInputChannels
if (is.defined(inputOptions.limitInputChannels)) {
if (is.bool(inputOptions.limitInputChannels)) {
inputDescriptor.limitInputChannels = inputOptions.limitInputChannels ? 5 : 0;
} else if (is.integer(inputOptions.limitInputChannels) && is.inRange(inputOptions.limitInputChannels, 0, Number.MAX_SAFE_INTEGER)) {
inputDescriptor.limitInputChannels = inputOptions.limitInputChannels;
} else {
throw is.invalidParameterError('limitInputChannels', 'positive integer', inputOptions.limitInputChannels);
}
}
// unlimited

@@ -157,0 +168,0 @@ if (is.defined(inputOptions.unlimited)) {

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

*
* Use the `lineArt` and `threshold` options for control over sensitivity.
*
* The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.

@@ -511,0 +513,0 @@ *

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

*
* Use the `lineArt` and `threshold` options for control over sensitivity.
*
* The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.

@@ -511,0 +513,0 @@ *

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

const { familySync, versionSync } = require("detect-libc");

@@ -14,2 +15,3 @@

const { version } = pkg;

@@ -16,0 +18,0 @@

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

const events = require('node:events');
const { availableParallelism } = require("node:os");

@@ -16,2 +17,3 @@ const detectLibc = require('detect-libc');

const runtimePlatform = libvips.runtimePlatformArch();

@@ -18,0 +20,0 @@ const libvipsVersion = sharp.libvipsVersion();

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

@@ -155,40 +155,40 @@ "homepage": "https://sharp.pixelplumbing.com",

"detect-libc": "^2.1.2",
"semver": "^7.7.4"
"semver": "^7.8.2"
},
"optionalDependencies": {
"@img/sharp-darwin-arm64": "0.35.0-rc.5",
"@img/sharp-darwin-x64": "0.35.0-rc.5",
"@img/sharp-freebsd-wasm32": "0.35.0-rc.5",
"@img/sharp-libvips-darwin-arm64": "1.3.0-rc.5",
"@img/sharp-libvips-darwin-x64": "1.3.0-rc.5",
"@img/sharp-libvips-linux-arm": "1.3.0-rc.5",
"@img/sharp-libvips-linux-arm64": "1.3.0-rc.5",
"@img/sharp-libvips-linux-ppc64": "1.3.0-rc.5",
"@img/sharp-libvips-linux-riscv64": "1.3.0-rc.5",
"@img/sharp-libvips-linux-s390x": "1.3.0-rc.5",
"@img/sharp-libvips-linux-x64": "1.3.0-rc.5",
"@img/sharp-libvips-linuxmusl-arm64": "1.3.0-rc.5",
"@img/sharp-libvips-linuxmusl-x64": "1.3.0-rc.5",
"@img/sharp-linux-arm": "0.35.0-rc.5",
"@img/sharp-linux-arm64": "0.35.0-rc.5",
"@img/sharp-linux-ppc64": "0.35.0-rc.5",
"@img/sharp-linux-riscv64": "0.35.0-rc.5",
"@img/sharp-linux-s390x": "0.35.0-rc.5",
"@img/sharp-linux-x64": "0.35.0-rc.5",
"@img/sharp-linuxmusl-arm64": "0.35.0-rc.5",
"@img/sharp-linuxmusl-x64": "0.35.0-rc.5",
"@img/sharp-webcontainers-wasm32": "0.35.0-rc.5",
"@img/sharp-win32-arm64": "0.35.0-rc.5",
"@img/sharp-win32-ia32": "0.35.0-rc.5",
"@img/sharp-win32-x64": "0.35.0-rc.5"
"@img/sharp-darwin-arm64": "0.35.0-rc.6",
"@img/sharp-darwin-x64": "0.35.0-rc.6",
"@img/sharp-freebsd-wasm32": "0.35.0-rc.6",
"@img/sharp-libvips-darwin-arm64": "1.3.0-rc.8",
"@img/sharp-libvips-darwin-x64": "1.3.0-rc.8",
"@img/sharp-libvips-linux-arm": "1.3.0-rc.8",
"@img/sharp-libvips-linux-arm64": "1.3.0-rc.8",
"@img/sharp-libvips-linux-ppc64": "1.3.0-rc.8",
"@img/sharp-libvips-linux-riscv64": "1.3.0-rc.8",
"@img/sharp-libvips-linux-s390x": "1.3.0-rc.8",
"@img/sharp-libvips-linux-x64": "1.3.0-rc.8",
"@img/sharp-libvips-linuxmusl-arm64": "1.3.0-rc.8",
"@img/sharp-libvips-linuxmusl-x64": "1.3.0-rc.8",
"@img/sharp-linux-arm": "0.35.0-rc.6",
"@img/sharp-linux-arm64": "0.35.0-rc.6",
"@img/sharp-linux-ppc64": "0.35.0-rc.6",
"@img/sharp-linux-riscv64": "0.35.0-rc.6",
"@img/sharp-linux-s390x": "0.35.0-rc.6",
"@img/sharp-linux-x64": "0.35.0-rc.6",
"@img/sharp-linuxmusl-arm64": "0.35.0-rc.6",
"@img/sharp-linuxmusl-x64": "0.35.0-rc.6",
"@img/sharp-webcontainers-wasm32": "0.35.0-rc.6",
"@img/sharp-win32-arm64": "0.35.0-rc.6",
"@img/sharp-win32-ia32": "0.35.0-rc.6",
"@img/sharp-win32-x64": "0.35.0-rc.6"
},
"devDependencies": {
"@biomejs/biome": "^2.4.12",
"@biomejs/biome": "^2.4.16",
"@cpplint/cli": "^0.1.0",
"@emnapi/runtime": "^1.10.0",
"@img/sharp-libvips-dev": "1.3.0-rc.5",
"@img/sharp-libvips-dev-wasm32": "1.3.0-rc.5",
"@img/sharp-libvips-win32-arm64": "1.3.0-rc.5",
"@img/sharp-libvips-win32-ia32": "1.3.0-rc.5",
"@img/sharp-libvips-win32-x64": "1.3.0-rc.5",
"@img/sharp-libvips-dev": "1.3.0-rc.8",
"@img/sharp-libvips-dev-wasm32": "1.3.0-rc.8",
"@img/sharp-libvips-win32-arm64": "1.3.0-rc.8",
"@img/sharp-libvips-win32-ia32": "1.3.0-rc.8",
"@img/sharp-libvips-win32-x64": "1.3.0-rc.8",
"@types/node": "*",

@@ -198,5 +198,5 @@ "emnapi": "^1.10.0",

"extract-zip": "^2.0.1",
"icc": "^3.0.0",
"node-addon-api": "^8.7.0",
"node-gyp": "^12.3.0",
"icc": "^4.0.0",
"node-addon-api": "^8.8.0",
"node-gyp": "^12.4.0",
"tar-fs": "^3.1.2",

@@ -210,3 +210,3 @@ "tsd": "^0.33.0"

"config": {
"libvips": ">=8.18.2"
"libvips": ">=8.18.3"
},

@@ -213,0 +213,0 @@ "funding": {

@@ -199,4 +199,4 @@ /*!

}
// Limit input images to a given number of pixels, where pixels = width * height
descriptor->limitInputPixels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputPixels"));
descriptor->limitInputChannels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputChannels"));
if (HasAttr(input, "access")) {

@@ -618,2 +618,5 @@ descriptor->access = AttrAsBool(input, "sequentialRead") ? VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM;

}
if (descriptor->limitInputChannels > 0 && static_cast<uint64_t>(image.bands()) > descriptor->limitInputChannels) {
throw std::runtime_error("Input image exceeds channel limit");
}
return std::make_tuple(image, imageType);

@@ -620,0 +623,0 @@ }

@@ -22,4 +22,4 @@ /*!

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

@@ -50,2 +50,3 @@

uint64_t limitInputPixels;
uint64_t limitInputChannels;
bool unlimited;

@@ -103,2 +104,3 @@ VipsAccess access;

limitInputPixels(0x3FFF * 0x3FFF),
limitInputChannels(5),
unlimited(false),

@@ -105,0 +107,0 @@ access(VIPS_ACCESS_SEQUENTIAL),

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

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

@@ -386,0 +386,0 @@ jxlDecodingTier(0),

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

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

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