+22
-11
@@ -138,2 +138,22 @@ // Copyright 2013 Lovell Fuller and others. | ||
| /** | ||
| * Create a RGBA colour array from a given value. | ||
| * @private | ||
| * @param {string|Object} value | ||
| * @throws {Error} Invalid value | ||
| */ | ||
| function _getBackgroundColourOption (value) { | ||
| if (is.object(value) || is.string(value)) { | ||
| const colour = color(value); | ||
| return [ | ||
| colour.red(), | ||
| colour.green(), | ||
| colour.blue(), | ||
| Math.round(colour.alpha() * 255) | ||
| ]; | ||
| } else { | ||
| throw is.invalidParameterError('background', 'object or string', value); | ||
| } | ||
| } | ||
| /** | ||
| * Update a colour attribute of the this.options Object. | ||
@@ -147,13 +167,3 @@ * @private | ||
| if (is.defined(value)) { | ||
| if (is.object(value) || is.string(value)) { | ||
| const colour = color(value); | ||
| this.options[key] = [ | ||
| colour.red(), | ||
| colour.green(), | ||
| colour.blue(), | ||
| Math.round(colour.alpha() * 255) | ||
| ]; | ||
| } else { | ||
| throw is.invalidParameterError('background', 'object or string', value); | ||
| } | ||
| this.options[key] = _getBackgroundColourOption(value); | ||
| } | ||
@@ -178,2 +188,3 @@ } | ||
| // Private | ||
| _getBackgroundColourOption, | ||
| _setBackgroundColourOption | ||
@@ -180,0 +191,0 @@ }); |
@@ -301,3 +301,3 @@ // Copyright 2013 Lovell Fuller and others. | ||
| resolveWithObject: false, | ||
| loop: 1, | ||
| loop: -1, | ||
| delay: [], | ||
@@ -304,0 +304,0 @@ // output format |
+3
-16
@@ -6,3 +6,2 @@ // Copyright 2013 Lovell Fuller and others. | ||
| const color = require('color'); | ||
| const is = require('./is'); | ||
@@ -253,3 +252,3 @@ const sharp = require('./sharp'); | ||
| if (is.defined(inputOptions.pdfBackground)) { | ||
| this._setBackgroundColourOption('pdfBackground', inputOptions.pdfBackground); | ||
| inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdfBackground); | ||
| } | ||
@@ -293,9 +292,3 @@ // Create new image | ||
| } | ||
| const background = color(inputOptions.create.background); | ||
| inputDescriptor.createBackground = [ | ||
| background.red(), | ||
| background.green(), | ||
| background.blue(), | ||
| Math.round(background.alpha() * 255) | ||
| ]; | ||
| inputDescriptor.createBackground = this._getBackgroundColourOption(inputOptions.create.background); | ||
| } else { | ||
@@ -416,9 +409,3 @@ throw new Error('Expected valid noise or background to create a new input image'); | ||
| if (is.defined(inputOptions.join.background)) { | ||
| const background = color(inputOptions.join.background); | ||
| inputDescriptor.joinBackground = [ | ||
| background.red(), | ||
| background.green(), | ||
| background.blue(), | ||
| Math.round(background.alpha() * 255) | ||
| ]; | ||
| inputDescriptor.joinBackground = this._getBackgroundColourOption(inputOptions.join.background); | ||
| } | ||
@@ -425,0 +412,0 @@ if (is.defined(inputOptions.join.halign)) { |
+2
-2
@@ -21,5 +21,5 @@ // Copyright 2013 Lovell Fuller and others. | ||
| 'darwin-arm64', 'darwin-x64', | ||
| 'linux-arm', 'linux-arm64', 'linux-s390x', 'linux-x64', | ||
| 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-s390x', 'linux-x64', | ||
| 'linuxmusl-arm64', 'linuxmusl-x64', | ||
| 'win32-ia32', 'win32-x64' | ||
| 'win32-arm64', 'win32-ia32', 'win32-x64' | ||
| ]; | ||
@@ -26,0 +26,0 @@ |
+1
-8
@@ -6,3 +6,2 @@ // Copyright 2013 Lovell Fuller and others. | ||
| const color = require('color'); | ||
| const is = require('./is'); | ||
@@ -71,9 +70,3 @@ | ||
| if (is.object(options) && options.background) { | ||
| const backgroundColour = color(options.background); | ||
| this.options.rotationBackground = [ | ||
| backgroundColour.red(), | ||
| backgroundColour.green(), | ||
| backgroundColour.blue(), | ||
| Math.round(backgroundColour.alpha() * 255) | ||
| ]; | ||
| this._setBackgroundColourOption('rotationBackground', options.background); | ||
| } | ||
@@ -80,0 +73,0 @@ } else { |
+1
-1
@@ -132,3 +132,3 @@ // Copyright 2013 Lovell Fuller and others. | ||
| * | ||
| * <img alt="Examples of various values for the fit property when resizing" width="100%" style="aspect-ratio: 998/243" src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/image/api-resize-fit.svg"> | ||
| * <img alt="Examples of various values for the fit property when resizing" width="100%" style="aspect-ratio: 998/243" src="/api-resize-fit.svg"> | ||
| * | ||
@@ -135,0 +135,0 @@ * When using a **fit** of `cover` or `contain`, the default **position** is `centre`. Other options are: |
+20
-18
| { | ||
| "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.1", | ||
| "version": "0.34.2-rc.0", | ||
| "author": "Lovell Fuller <npm@lovell.info>", | ||
@@ -141,8 +141,8 @@ "homepage": "https://sharp.pixelplumbing.com", | ||
| "color": "^4.2.3", | ||
| "detect-libc": "^2.0.3", | ||
| "semver": "^7.7.1" | ||
| "detect-libc": "^2.0.4", | ||
| "semver": "^7.7.2" | ||
| }, | ||
| "optionalDependencies": { | ||
| "@img/sharp-darwin-arm64": "0.34.1", | ||
| "@img/sharp-darwin-x64": "0.34.1", | ||
| "@img/sharp-darwin-arm64": "0.34.2-rc.0", | ||
| "@img/sharp-darwin-x64": "0.34.2-rc.0", | ||
| "@img/sharp-libvips-darwin-arm64": "1.1.0", | ||
@@ -157,16 +157,18 @@ "@img/sharp-libvips-darwin-x64": "1.1.0", | ||
| "@img/sharp-libvips-linuxmusl-x64": "1.1.0", | ||
| "@img/sharp-linux-arm": "0.34.1", | ||
| "@img/sharp-linux-arm64": "0.34.1", | ||
| "@img/sharp-linux-s390x": "0.34.1", | ||
| "@img/sharp-linux-x64": "0.34.1", | ||
| "@img/sharp-linuxmusl-arm64": "0.34.1", | ||
| "@img/sharp-linuxmusl-x64": "0.34.1", | ||
| "@img/sharp-wasm32": "0.34.1", | ||
| "@img/sharp-win32-ia32": "0.34.1", | ||
| "@img/sharp-win32-x64": "0.34.1" | ||
| "@img/sharp-linux-arm": "0.34.2-rc.0", | ||
| "@img/sharp-linux-arm64": "0.34.2-rc.0", | ||
| "@img/sharp-linux-s390x": "0.34.2-rc.0", | ||
| "@img/sharp-linux-x64": "0.34.2-rc.0", | ||
| "@img/sharp-linuxmusl-arm64": "0.34.2-rc.0", | ||
| "@img/sharp-linuxmusl-x64": "0.34.2-rc.0", | ||
| "@img/sharp-wasm32": "0.34.2-rc.0", | ||
| "@img/sharp-win32-arm64": "0.34.2-rc.0", | ||
| "@img/sharp-win32-ia32": "0.34.2-rc.0", | ||
| "@img/sharp-win32-x64": "0.34.2-rc.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@emnapi/runtime": "^1.4.0", | ||
| "@emnapi/runtime": "^1.4.3", | ||
| "@img/sharp-libvips-dev": "1.1.0", | ||
| "@img/sharp-libvips-dev-wasm32": "1.1.0", | ||
| "@img/sharp-libvips-win32-arm64": "1.1.0", | ||
| "@img/sharp-libvips-win32-ia32": "1.1.0", | ||
@@ -176,3 +178,3 @@ "@img/sharp-libvips-win32-x64": "1.1.0", | ||
| "cc": "^3.0.1", | ||
| "emnapi": "^1.4.0", | ||
| "emnapi": "^1.4.3", | ||
| "exif-reader": "^2.0.2", | ||
@@ -183,3 +185,3 @@ "extract-zip": "^2.0.1", | ||
| "license-checker": "^25.0.1", | ||
| "mocha": "^11.1.0", | ||
| "mocha": "^11.2.2", | ||
| "node-addon-api": "^8.3.1", | ||
@@ -190,3 +192,3 @@ "nyc": "^17.1.0", | ||
| "tar-fs": "^3.0.8", | ||
| "tsd": "^0.31.2" | ||
| "tsd": "^0.32.0" | ||
| }, | ||
@@ -193,0 +195,0 @@ "license": "Apache-2.0", |
+1
-1
| # sharp | ||
| <img src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/public/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right"> | ||
| <img src="https://sharp.pixelplumbing.com/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right"> | ||
@@ -5,0 +5,0 @@ The typical use case for this high speed Node-API module |
+15
-26
@@ -654,12 +654,2 @@ // Copyright 2013 Lovell Fuller and others. | ||
| bool hasDelay = !delay.empty(); | ||
| // Avoid a copy if none of the animation properties are needed. | ||
| if (nPages == 1 && !hasDelay && loop == -1) return image; | ||
| if (delay.size() == 1) { | ||
| // We have just one delay, repeat that value for all frames. | ||
| delay.insert(delay.end(), nPages - 1, delay[0]); | ||
| } | ||
| // Attaching metadata, need to copy the image. | ||
| VImage copy = image.copy(); | ||
@@ -670,3 +660,12 @@ | ||
| if (nPages > 1) copy.set(VIPS_META_PAGE_HEIGHT, pageHeight); | ||
| if (hasDelay) copy.set("delay", delay); | ||
| if (hasDelay) { | ||
| if (delay.size() == 1) { | ||
| // We have just one delay, repeat that value for all frames. | ||
| delay.insert(delay.end(), nPages - 1, delay[0]); | ||
| } | ||
| copy.set("delay", delay); | ||
| } | ||
| if (nPages == 1 && !hasDelay && loop == -1) { | ||
| loop = 1; | ||
| } | ||
| if (loop != -1) copy.set("loop", loop); | ||
@@ -958,10 +957,2 @@ | ||
| /* | ||
| Return the image alpha maximum. Useful for combining alpha bands. scRGB | ||
| images are 0 - 1 for image data, but the alpha is 0 - 255. | ||
| */ | ||
| double MaximumImageAlpha(VipsInterpretation const interpretation) { | ||
| return Is16Bit(interpretation) ? 65535.0 : 255.0; | ||
| } | ||
| /* | ||
| Convert RGBA value to another colourspace | ||
@@ -1008,5 +999,6 @@ */ | ||
| } | ||
| // Add alpha channel to alphaColour colour | ||
| // Add alpha channel(s) to alphaColour colour | ||
| if (colour[3] < 255.0 || image.has_alpha()) { | ||
| alphaColour.push_back(colour[3] * multiplier); | ||
| int extraBands = image.bands() > 4 ? image.bands() - 3 : 1; | ||
| alphaColour.insert(alphaColour.end(), extraBands, colour[3] * multiplier); | ||
| } | ||
@@ -1017,4 +1009,3 @@ // Ensure alphaColour colour uses correct colourspace | ||
| if (colour[3] < 255.0 && !image.has_alpha()) { | ||
| image = image.bandjoin( | ||
| VImage::new_matrix(image.width(), image.height()).new_from_image(255 * multiplier).cast(image.format())); | ||
| image = image.bandjoin_const({ 255 * multiplier }); | ||
| } | ||
@@ -1039,5 +1030,3 @@ return std::make_tuple(image, alphaColour); | ||
| if (!image.has_alpha()) { | ||
| std::vector<double> alpha; | ||
| alpha.push_back(value * sharp::MaximumImageAlpha(image.interpretation())); | ||
| image = image.bandjoin_const(alpha); | ||
| image = image.bandjoin_const({ value * vips_interpretation_max_alpha(image.interpretation()) }); | ||
| } | ||
@@ -1044,0 +1033,0 @@ return image; |
+0
-6
@@ -361,8 +361,2 @@ // Copyright 2013 Lovell Fuller and others. | ||
| /* | ||
| Return the image alpha maximum. Useful for combining alpha bands. scRGB | ||
| images are 0 - 1 for image data, but the alpha is 0 - 255. | ||
| */ | ||
| double MaximumImageAlpha(VipsInterpretation const interpretation); | ||
| /* | ||
| Convert RGBA value to another colourspace | ||
@@ -369,0 +363,0 @@ */ |
+1
-1
@@ -387,3 +387,3 @@ // Copyright 2013 Lovell Fuller and others. | ||
| colourspace(VIPS_INTERPRETATION_LAST), | ||
| loop(1), | ||
| loop(-1), | ||
| tileSize(256), | ||
@@ -390,0 +390,0 @@ tileOverlap(0), |
+1
-1
@@ -63,3 +63,3 @@ // Copyright 2013 Lovell Fuller and others. | ||
| double const minAlpha = static_cast<double>(stats.getpoint(STAT_MIN_INDEX, bands).front()); | ||
| if (minAlpha != sharp::MaximumImageAlpha(image.interpretation())) { | ||
| if (minAlpha != vips_interpretation_max_alpha(image.interpretation())) { | ||
| baton->isOpaque = false; | ||
@@ -66,0 +66,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
522379
0.04%7347
0.33%24
4.35%21
5%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated