Compare commits

..

No commits in common. "ef86a75560adb40605d3dfc85dc3656a0b88c413" and "e1628d8ef5033dedde9ed1ddd4dd681e1fc30e1e" have entirely different histories.

19 changed files with 57 additions and 52 deletions

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://biomejs.dev/schemas/2.3.4/schema.json", "$schema": "https://biomejs.dev/schemas/2.3.3/schema.json",
"vcs": { "vcs": {
"enabled": true, "enabled": true,
"clientKind": "git", "clientKind": "git",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{ {
"name": "sharp", "name": "sharp",
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images", "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
"version": "0.34.5-rc.0", "version": "0.34.4",
"author": "Lovell Fuller <npm@lovell.info>", "author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com", "homepage": "https://sharp.pixelplumbing.com",
"contributors": [ "contributors": [
@ -144,8 +144,8 @@
"semver": "^7.7.3" "semver": "^7.7.3"
}, },
"optionalDependencies": { "optionalDependencies": {
"@img/sharp-darwin-arm64": "0.34.5-rc.0", "@img/sharp-darwin-arm64": "0.34.4",
"@img/sharp-darwin-x64": "0.34.5-rc.0", "@img/sharp-darwin-x64": "0.34.4",
"@img/sharp-libvips-darwin-arm64": "1.2.4", "@img/sharp-libvips-darwin-arm64": "1.2.4",
"@img/sharp-libvips-darwin-x64": "1.2.4", "@img/sharp-libvips-darwin-x64": "1.2.4",
"@img/sharp-libvips-linux-arm": "1.2.4", "@img/sharp-libvips-linux-arm": "1.2.4",
@ -156,30 +156,30 @@
"@img/sharp-libvips-linux-x64": "1.2.4", "@img/sharp-libvips-linux-x64": "1.2.4",
"@img/sharp-libvips-linuxmusl-arm64": "1.2.4", "@img/sharp-libvips-linuxmusl-arm64": "1.2.4",
"@img/sharp-libvips-linuxmusl-x64": "1.2.4", "@img/sharp-libvips-linuxmusl-x64": "1.2.4",
"@img/sharp-linux-arm": "0.34.5-rc.0", "@img/sharp-linux-arm": "0.34.4",
"@img/sharp-linux-arm64": "0.34.5-rc.0", "@img/sharp-linux-arm64": "0.34.4",
"@img/sharp-linux-ppc64": "0.34.5-rc.0", "@img/sharp-linux-ppc64": "0.34.4",
"@img/sharp-linux-riscv64": "0.34.5-rc.0", "@img/sharp-linux-riscv64": "0.34.4",
"@img/sharp-linux-s390x": "0.34.5-rc.0", "@img/sharp-linux-s390x": "0.34.4",
"@img/sharp-linux-x64": "0.34.5-rc.0", "@img/sharp-linux-x64": "0.34.4",
"@img/sharp-linuxmusl-arm64": "0.34.5-rc.0", "@img/sharp-linuxmusl-arm64": "0.34.4",
"@img/sharp-linuxmusl-x64": "0.34.5-rc.0", "@img/sharp-linuxmusl-x64": "0.34.4",
"@img/sharp-wasm32": "0.34.5-rc.0", "@img/sharp-wasm32": "0.34.4",
"@img/sharp-win32-arm64": "0.34.5-rc.0", "@img/sharp-win32-arm64": "0.34.4",
"@img/sharp-win32-ia32": "0.34.5-rc.0", "@img/sharp-win32-ia32": "0.34.4",
"@img/sharp-win32-x64": "0.34.5-rc.0" "@img/sharp-win32-x64": "0.34.4"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^2.3.4", "@biomejs/biome": "^2.3.3",
"@cpplint/cli": "^0.1.0", "@cpplint/cli": "^0.1.0",
"@emnapi/runtime": "^1.7.0", "@emnapi/runtime": "^1.6.0",
"@img/sharp-libvips-dev": "1.2.4", "@img/sharp-libvips-dev": "1.2.4",
"@img/sharp-libvips-dev-wasm32": "1.2.4", "@img/sharp-libvips-dev-wasm32": "1.2.4",
"@img/sharp-libvips-win32-arm64": "1.2.4", "@img/sharp-libvips-win32-arm64": "1.2.4",
"@img/sharp-libvips-win32-ia32": "1.2.4", "@img/sharp-libvips-win32-ia32": "1.2.4",
"@img/sharp-libvips-win32-x64": "1.2.4", "@img/sharp-libvips-win32-x64": "1.2.4",
"@types/node": "*", "@types/node": "*",
"emnapi": "^1.7.0", "emnapi": "^1.6.0",
"exif-reader": "^2.0.2", "exif-reader": "^2.0.2",
"extract-zip": "^2.0.1", "extract-zip": "^2.0.1",
"icc": "^3.0.0", "icc": "^3.0.0",

View File

@ -219,10 +219,10 @@ class MetadataWorker : public Napi::AsyncWorker {
if (!baton->levels.empty()) { if (!baton->levels.empty()) {
int i = 0; int i = 0;
Napi::Array levels = Napi::Array::New(env, static_cast<size_t>(baton->levels.size())); Napi::Array levels = Napi::Array::New(env, static_cast<size_t>(baton->levels.size()));
for (const auto& [width, height] : baton->levels) { for (std::pair<int, int> const &l : baton->levels) {
Napi::Object level = Napi::Object::New(env); Napi::Object level = Napi::Object::New(env);
level.Set("width", width); level.Set("width", l.first);
level.Set("height", height); level.Set("height", l.second);
levels.Set(i++, level); levels.Set(i++, level);
} }
info.Set("levels", levels); info.Set("levels", levels);
@ -279,10 +279,10 @@ class MetadataWorker : public Napi::AsyncWorker {
if (baton->comments.size() > 0) { if (baton->comments.size() > 0) {
int i = 0; int i = 0;
Napi::Array comments = Napi::Array::New(env, baton->comments.size()); Napi::Array comments = Napi::Array::New(env, baton->comments.size());
for (const auto& [keyword, text] : baton->comments) { for (auto &c : baton->comments) {
Napi::Object comment = Napi::Object::New(env); Napi::Object comment = Napi::Object::New(env);
comment.Set("keyword", keyword); comment.Set("keyword", c.first);
comment.Set("text", text); comment.Set("text", c.second);
comments.Set(i++, comment); comments.Set(i++, comment);
} }
info.Set("comments", comments); info.Set("comments", comments);

View File

@ -455,10 +455,12 @@ class PipelineWorker : public Napi::AsyncWorker {
std::tie(image, background) = sharp::ApplyAlpha(image, baton->resizeBackground, shouldPremultiplyAlpha); std::tie(image, background) = sharp::ApplyAlpha(image, baton->resizeBackground, shouldPremultiplyAlpha);
// Embed // Embed
const auto& [left, top] = sharp::CalculateEmbedPosition( int left;
int top;
std::tie(left, top) = sharp::CalculateEmbedPosition(
inputWidth, inputHeight, baton->width, baton->height, baton->position); inputWidth, inputHeight, baton->width, baton->height, baton->position);
const int width = std::max(inputWidth, baton->width); int width = std::max(inputWidth, baton->width);
const int height = std::max(inputHeight, baton->height); int height = std::max(inputHeight, baton->height);
image = nPages > 1 image = nPages > 1
? sharp::EmbedMultiPage(image, ? sharp::EmbedMultiPage(image,
@ -477,10 +479,13 @@ class PipelineWorker : public Napi::AsyncWorker {
// Crop // Crop
if (baton->position < 9) { if (baton->position < 9) {
// Gravity-based crop // Gravity-based crop
const auto& [left, top] = sharp::CalculateCrop( int left;
int top;
std::tie(left, top) = sharp::CalculateCrop(
inputWidth, inputHeight, baton->width, baton->height, baton->position); inputWidth, inputHeight, baton->width, baton->height, baton->position);
const int width = std::min(inputWidth, baton->width); int width = std::min(inputWidth, baton->width);
const int height = std::min(inputHeight, baton->height); int height = std::min(inputHeight, baton->height);
image = nPages > 1 image = nPages > 1
? sharp::CropMultiPage(image, ? sharp::CropMultiPage(image,
@ -798,7 +803,7 @@ class PipelineWorker : public Napi::AsyncWorker {
} }
if (image.interpretation() != baton->colourspace) { if (image.interpretation() != baton->colourspace) {
image = image.colourspace(baton->colourspace, VImage::option()->set("source_space", image.interpretation())); image = image.colourspace(baton->colourspace, VImage::option()->set("source_space", image.interpretation()));
if (inputProfile.first != nullptr && baton->withIccProfile.empty()) { if (inputProfile.first && baton->withIccProfile.empty()) {
image = sharp::SetProfile(image, inputProfile); image = sharp::SetProfile(image, inputProfile);
} }
} }
@ -855,8 +860,8 @@ class PipelineWorker : public Napi::AsyncWorker {
if (!baton->withExifMerge) { if (!baton->withExifMerge) {
image = sharp::RemoveExif(image); image = sharp::RemoveExif(image);
} }
for (const auto& [key, value] : baton->withExif) { for (const auto& s : baton->withExif) {
image.set(key.c_str(), value.c_str()); image.set(s.first.data(), s.second.data());
} }
} }
// XMP buffer // XMP buffer
@ -1435,11 +1440,11 @@ class PipelineWorker : public Napi::AsyncWorker {
std::string std::string
AssembleSuffixString(std::string extname, std::vector<std::pair<std::string, std::string>> options) { AssembleSuffixString(std::string extname, std::vector<std::pair<std::string, std::string>> options) {
std::string argument; std::string argument;
for (const auto& [key, value] : options) { for (auto const &option : options) {
if (!argument.empty()) { if (!argument.empty()) {
argument += ","; argument += ",";
} }
argument += key + "=" + value; argument += option.first + "=" + option.second;
} }
return extname + "[" + argument + "]"; return extname + "[" + argument + "]";
} }