Compare commits

...

5 Commits

Author SHA1 Message Date
Lovell Fuller
956d72ddc0 Prerelease v0.34.2-rc.0 2025-05-14 12:37:15 +01:00
Lovell Fuller
00e66efbee Bump deps 2025-05-14 12:37:08 +01:00
Kleis Auke Wolthuizen
db3a4528eb Simplify 94481a9 2025-05-13 19:22:36 +01:00
Kleis Auke Wolthuizen
d36fd5064d Prefer use of bandjoin_const() and list-initialization 2025-05-13 19:22:36 +01:00
Kleis Auke Wolthuizen
8e17c6f518 Prefer use of vips_interpretation_max_alpha()
This also ensures we handle scRGB correctly, see:
e9c5a31552
2025-05-13 19:22:36 +01:00
18 changed files with 39 additions and 57 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-darwin-arm64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with macOS 64-bit ARM",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-darwin-x64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with macOS x64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linux-arm",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (glibc) ARM (32-bit)",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linux-arm64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (glibc) 64-bit ARM",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linux-ppc64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (glibc) ppc64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linux-s390x",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (glibc) s390x",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linux-x64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (glibc) x64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linuxmusl-arm64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (musl) 64-bit ARM",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-linuxmusl-x64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Linux (musl) x64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"private": "true",
"workspaces": [
"darwin-arm64",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-wasm32",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with wasm32",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",
@@ -31,7 +31,7 @@
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"dependencies": {
"@emnapi/runtime": "^1.4.0"
"@emnapi/runtime": "^1.4.3"
},
"cpu": [
"wasm32"

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-win32-arm64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Windows 64-bit ARM",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-win32-ia32",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Windows x86 (32-bit)",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@img/sharp-win32-x64",
"version": "0.34.1",
"version": "0.34.2-rc.0",
"description": "Prebuilt sharp for use with Windows x64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",

View File

@@ -1,7 +1,7 @@
{
"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>",
"homepage": "https://sharp.pixelplumbing.com",
"contributors": [
@@ -138,12 +138,12 @@
],
"dependencies": {
"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",
"@img/sharp-libvips-darwin-x64": "1.1.0",
"@img/sharp-libvips-linux-arm": "1.1.0",
@@ -153,19 +153,19 @@
"@img/sharp-libvips-linux-x64": "1.1.0",
"@img/sharp-libvips-linuxmusl-arm64": "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-arm64": "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",
@@ -173,19 +173,19 @@
"@img/sharp-libvips-win32-x64": "1.1.0",
"@types/node": "*",
"cc": "^3.0.1",
"emnapi": "^1.4.0",
"emnapi": "^1.4.3",
"exif-reader": "^2.0.2",
"extract-zip": "^2.0.1",
"icc": "^3.0.0",
"jsdoc-to-markdown": "^9.1.1",
"license-checker": "^25.0.1",
"mocha": "^11.1.0",
"mocha": "^11.2.2",
"node-addon-api": "^8.3.1",
"nyc": "^17.1.0",
"prebuild": "^13.0.1",
"semistandard": "^17.0.0",
"tar-fs": "^3.0.8",
"tsd": "^0.31.2"
"tsd": "^0.32.0"
},
"license": "Apache-2.0",
"engines": {

View File

@@ -951,14 +951,6 @@ namespace sharp {
return interpretation == VIPS_INTERPRETATION_RGB16 || interpretation == VIPS_INTERPRETATION_GREY16;
}
/*
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
*/
@@ -1003,16 +995,14 @@ namespace sharp {
}
// Add alpha channel(s) to alphaColour colour
if (colour[3] < 255.0 || image.has_alpha()) {
do {
alphaColour.push_back(colour[3] * multiplier);
} while (alphaColour.size() < static_cast<size_t>(image.bands()));
int extraBands = image.bands() > 4 ? image.bands() - 3 : 1;
alphaColour.insert(alphaColour.end(), extraBands, colour[3] * multiplier);
}
// Ensure alphaColour colour uses correct colourspace
alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation(), premultiply);
// Add non-transparent alpha channel, if required
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 });
}
return std::make_tuple(image, alphaColour);
}
@@ -1032,9 +1022,7 @@ namespace sharp {
*/
VImage EnsureAlpha(VImage image, double const value) {
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()) });
}
return image;
}

View File

@@ -357,12 +357,6 @@ namespace sharp {
*/
bool Is16Bit(VipsInterpretation const interpretation);
/*
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
*/

View File

@@ -60,7 +60,7 @@ class StatsWorker : public Napi::AsyncWorker {
// Image is not opaque when alpha layer is present and contains a non-mamixa value
if (image.has_alpha()) {
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;
}
}