mirror of
https://github.com/lovell/sharp.git
synced 2025-12-06 12:01:41 +01:00
Compare commits
2 Commits
e1628d8ef5
...
ef86a75560
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef86a75560 | ||
|
|
6c1e840098 |
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/2.3.3/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.3.4/schema.json",
|
||||||
"vcs": {
|
"vcs": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"clientKind": "git",
|
"clientKind": "git",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-darwin-arm64",
|
"name": "@img/sharp-darwin-arm64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-darwin-x64",
|
"name": "@img/sharp-darwin-x64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-arm",
|
"name": "@img/sharp-linux-arm",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-arm64",
|
"name": "@img/sharp-linux-arm64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-ppc64",
|
"name": "@img/sharp-linux-ppc64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-riscv64",
|
"name": "@img/sharp-linux-riscv64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-s390x",
|
"name": "@img/sharp-linux-s390x",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-x64",
|
"name": "@img/sharp-linux-x64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linuxmusl-arm64",
|
"name": "@img/sharp-linuxmusl-arm64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linuxmusl-x64",
|
"name": "@img/sharp-linuxmusl-x64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp",
|
"name": "@img/sharp",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"darwin-arm64",
|
"darwin-arm64",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-wasm32",
|
"name": "@img/sharp-wasm32",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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.6.0"
|
"@emnapi/runtime": "^1.7.0"
|
||||||
},
|
},
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-win32-arm64",
|
"name": "@img/sharp-win32-arm64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-win32-ia32",
|
"name": "@img/sharp-win32-ia32",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-win32-x64",
|
"name": "@img/sharp-win32-x64",
|
||||||
"version": "0.34.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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",
|
||||||
|
|||||||
36
package.json
36
package.json
@ -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.4",
|
"version": "0.34.5-rc.0",
|
||||||
"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.4",
|
"@img/sharp-darwin-arm64": "0.34.5-rc.0",
|
||||||
"@img/sharp-darwin-x64": "0.34.4",
|
"@img/sharp-darwin-x64": "0.34.5-rc.0",
|
||||||
"@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.4",
|
"@img/sharp-linux-arm": "0.34.5-rc.0",
|
||||||
"@img/sharp-linux-arm64": "0.34.4",
|
"@img/sharp-linux-arm64": "0.34.5-rc.0",
|
||||||
"@img/sharp-linux-ppc64": "0.34.4",
|
"@img/sharp-linux-ppc64": "0.34.5-rc.0",
|
||||||
"@img/sharp-linux-riscv64": "0.34.4",
|
"@img/sharp-linux-riscv64": "0.34.5-rc.0",
|
||||||
"@img/sharp-linux-s390x": "0.34.4",
|
"@img/sharp-linux-s390x": "0.34.5-rc.0",
|
||||||
"@img/sharp-linux-x64": "0.34.4",
|
"@img/sharp-linux-x64": "0.34.5-rc.0",
|
||||||
"@img/sharp-linuxmusl-arm64": "0.34.4",
|
"@img/sharp-linuxmusl-arm64": "0.34.5-rc.0",
|
||||||
"@img/sharp-linuxmusl-x64": "0.34.4",
|
"@img/sharp-linuxmusl-x64": "0.34.5-rc.0",
|
||||||
"@img/sharp-wasm32": "0.34.4",
|
"@img/sharp-wasm32": "0.34.5-rc.0",
|
||||||
"@img/sharp-win32-arm64": "0.34.4",
|
"@img/sharp-win32-arm64": "0.34.5-rc.0",
|
||||||
"@img/sharp-win32-ia32": "0.34.4",
|
"@img/sharp-win32-ia32": "0.34.5-rc.0",
|
||||||
"@img/sharp-win32-x64": "0.34.4"
|
"@img/sharp-win32-x64": "0.34.5-rc.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.3.3",
|
"@biomejs/biome": "^2.3.4",
|
||||||
"@cpplint/cli": "^0.1.0",
|
"@cpplint/cli": "^0.1.0",
|
||||||
"@emnapi/runtime": "^1.6.0",
|
"@emnapi/runtime": "^1.7.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.6.0",
|
"emnapi": "^1.7.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",
|
||||||
|
|||||||
@ -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 (std::pair<int, int> const &l : baton->levels) {
|
for (const auto& [width, height] : baton->levels) {
|
||||||
Napi::Object level = Napi::Object::New(env);
|
Napi::Object level = Napi::Object::New(env);
|
||||||
level.Set("width", l.first);
|
level.Set("width", width);
|
||||||
level.Set("height", l.second);
|
level.Set("height", height);
|
||||||
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 (auto &c : baton->comments) {
|
for (const auto& [keyword, text] : baton->comments) {
|
||||||
Napi::Object comment = Napi::Object::New(env);
|
Napi::Object comment = Napi::Object::New(env);
|
||||||
comment.Set("keyword", c.first);
|
comment.Set("keyword", keyword);
|
||||||
comment.Set("text", c.second);
|
comment.Set("text", text);
|
||||||
comments.Set(i++, comment);
|
comments.Set(i++, comment);
|
||||||
}
|
}
|
||||||
info.Set("comments", comments);
|
info.Set("comments", comments);
|
||||||
|
|||||||
@ -455,12 +455,10 @@ 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
|
||||||
int left;
|
const auto& [left, top] = sharp::CalculateEmbedPosition(
|
||||||
int top;
|
|
||||||
std::tie(left, top) = sharp::CalculateEmbedPosition(
|
|
||||||
inputWidth, inputHeight, baton->width, baton->height, baton->position);
|
inputWidth, inputHeight, baton->width, baton->height, baton->position);
|
||||||
int width = std::max(inputWidth, baton->width);
|
const int width = std::max(inputWidth, baton->width);
|
||||||
int height = std::max(inputHeight, baton->height);
|
const int height = std::max(inputHeight, baton->height);
|
||||||
|
|
||||||
image = nPages > 1
|
image = nPages > 1
|
||||||
? sharp::EmbedMultiPage(image,
|
? sharp::EmbedMultiPage(image,
|
||||||
@ -479,13 +477,10 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
// Crop
|
// Crop
|
||||||
if (baton->position < 9) {
|
if (baton->position < 9) {
|
||||||
// Gravity-based crop
|
// Gravity-based crop
|
||||||
int left;
|
const auto& [left, top] = sharp::CalculateCrop(
|
||||||
int top;
|
|
||||||
|
|
||||||
std::tie(left, top) = sharp::CalculateCrop(
|
|
||||||
inputWidth, inputHeight, baton->width, baton->height, baton->position);
|
inputWidth, inputHeight, baton->width, baton->height, baton->position);
|
||||||
int width = std::min(inputWidth, baton->width);
|
const int width = std::min(inputWidth, baton->width);
|
||||||
int height = std::min(inputHeight, baton->height);
|
const int height = std::min(inputHeight, baton->height);
|
||||||
|
|
||||||
image = nPages > 1
|
image = nPages > 1
|
||||||
? sharp::CropMultiPage(image,
|
? sharp::CropMultiPage(image,
|
||||||
@ -803,7 +798,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 && baton->withIccProfile.empty()) {
|
if (inputProfile.first != nullptr && baton->withIccProfile.empty()) {
|
||||||
image = sharp::SetProfile(image, inputProfile);
|
image = sharp::SetProfile(image, inputProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -860,8 +855,8 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
if (!baton->withExifMerge) {
|
if (!baton->withExifMerge) {
|
||||||
image = sharp::RemoveExif(image);
|
image = sharp::RemoveExif(image);
|
||||||
}
|
}
|
||||||
for (const auto& s : baton->withExif) {
|
for (const auto& [key, value] : baton->withExif) {
|
||||||
image.set(s.first.data(), s.second.data());
|
image.set(key.c_str(), value.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// XMP buffer
|
// XMP buffer
|
||||||
@ -1440,11 +1435,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 (auto const &option : options) {
|
for (const auto& [key, value] : options) {
|
||||||
if (!argument.empty()) {
|
if (!argument.empty()) {
|
||||||
argument += ",";
|
argument += ",";
|
||||||
}
|
}
|
||||||
argument += option.first + "=" + option.second;
|
argument += key + "=" + value;
|
||||||
}
|
}
|
||||||
return extname + "[" + argument + "]";
|
return extname + "[" + argument + "]";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user