mirror of
https://github.com/lovell/sharp.git
synced 2026-02-05 06:06:18 +01:00
Compare commits
30 Commits
v0.33.1-rc
...
v0.33.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcb22af034 | ||
|
|
d04dc62666 | ||
|
|
c30d355f97 | ||
|
|
49cb148b38 | ||
|
|
3bc31a8b20 | ||
|
|
c28523e70e | ||
|
|
278f393f74 | ||
|
|
cbf68c1395 | ||
|
|
45e8071599 | ||
|
|
b96389d975 | ||
|
|
a77ac6ae25 | ||
|
|
9bcf399b4c | ||
|
|
4aacee8055 | ||
|
|
0b18aeff62 | ||
|
|
bed1c2ac18 | ||
|
|
8cd832656b | ||
|
|
0499f59e71 | ||
|
|
1fa59bf9b3 | ||
|
|
db40ee6912 | ||
|
|
02b98b8e1b | ||
|
|
31fef216e4 | ||
|
|
77ab5d7a51 | ||
|
|
cd5cf7ce2d | ||
|
|
39cb9d9a6c | ||
|
|
4919bc5134 | ||
|
|
a4e64eb01f | ||
|
|
328b18df88 | ||
|
|
5e7bf32e5e | ||
|
|
04403f4e5f | ||
|
|
420e0822b4 |
15
.github/ISSUE_TEMPLATE/installation.md
vendored
15
.github/ISSUE_TEMPLATE/installation.md
vendored
@@ -24,7 +24,8 @@ You must confirm both of these before continuing.
|
|||||||
|
|
||||||
If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
|
If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
|
||||||
|
|
||||||
If you are using another package which depends on a version of `sharp` that is not the latest, please open an issue against that package instead.
|
If you are using another package which depends on a version of `sharp` that is not the latest,
|
||||||
|
please open an issue against that package instead.
|
||||||
|
|
||||||
### Are you using a supported runtime?
|
### Are you using a supported runtime?
|
||||||
|
|
||||||
@@ -43,15 +44,17 @@ and try again before opening an issue.
|
|||||||
<!-- Please place an [x] in the relevant box to confirm. -->
|
<!-- Please place an [x] in the relevant box to confirm. -->
|
||||||
|
|
||||||
- [ ] I am using npm >= 9.6.5 with `--include=optional`
|
- [ ] I am using npm >= 9.6.5 with `--include=optional`
|
||||||
- [ ] I am using yarn >= 3.2.0 and I am not using the "Plug'n'Play" linker
|
- [ ] I am using yarn >= 3.2.0
|
||||||
- [ ] I am using pnpm >= 7.1.0 with `--no-optional=false`
|
- [ ] I am using pnpm >= 7.1.0 with `--no-optional=false`
|
||||||
- [ ] I am using Deno
|
- [ ] I am using Deno
|
||||||
- [ ] I am using Bun
|
- [ ] I am using Bun
|
||||||
|
|
||||||
If you cannot confirm any of these,
|
If you cannot confirm any of these, please upgrade to the latest version of your chosen package manager
|
||||||
please upgrade to the latest version of your chosen package manager
|
and ensure you are allowing the installation of optional or multi-platform dependencies before opening an issue.
|
||||||
and ensure you are allowing the installation of optional or multi-platform dependencies
|
|
||||||
before opening an issue.
|
### What is the complete error message, including the full stack trace?
|
||||||
|
|
||||||
|
<!-- Please provide the error message and stack trace here. -->
|
||||||
|
|
||||||
### What is the complete output of running `npm install --verbose --foreground-scripts sharp` in an empty directory?
|
### What is the complete output of running `npm install --verbose --foreground-scripts sharp` in an empty directory?
|
||||||
|
|
||||||
|
|||||||
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
@@ -16,12 +16,14 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- os: ubuntu-22.04
|
- os: ubuntu-22.04
|
||||||
container: rockylinux:8
|
container: rockylinux:8
|
||||||
|
nodejs_arch: x64
|
||||||
nodejs_version: "^18.17.0"
|
nodejs_version: "^18.17.0"
|
||||||
nodejs_version_major: 18
|
nodejs_version_major: 18
|
||||||
platform: linux-x64
|
platform: linux-x64
|
||||||
prebuild: true
|
prebuild: true
|
||||||
- os: ubuntu-22.04
|
- os: ubuntu-22.04
|
||||||
container: rockylinux:8
|
container: rockylinux:8
|
||||||
|
nodejs_arch: x64
|
||||||
nodejs_version: "^20.3.0"
|
nodejs_version: "^20.3.0"
|
||||||
nodejs_version_major: 20
|
nodejs_version_major: 20
|
||||||
platform: linux-x64
|
platform: linux-x64
|
||||||
@@ -47,7 +49,7 @@ jobs:
|
|||||||
platform: darwin-x64
|
platform: darwin-x64
|
||||||
- os: windows-2019
|
- os: windows-2019
|
||||||
nodejs_arch: x86
|
nodejs_arch: x86
|
||||||
nodejs_version: "^18.17.0"
|
nodejs_version: "18.18.2" # pinned to avoid 18.19.0 and npm 10
|
||||||
nodejs_version_major: 18
|
nodejs_version_major: 18
|
||||||
platform: win32-ia32
|
platform: win32-ia32
|
||||||
prebuild: true
|
prebuild: true
|
||||||
@@ -68,19 +70,9 @@ jobs:
|
|||||||
nodejs_version_major: 20
|
nodejs_version_major: 20
|
||||||
platform: win32-x64
|
platform: win32-x64
|
||||||
steps:
|
steps:
|
||||||
- name: Dependencies (Linux glibc)
|
|
||||||
if: contains(matrix.container, 'centos')
|
|
||||||
run: |
|
|
||||||
yum install -y https://rpm.nodesource.com/pub_${{ matrix.nodejs_version_major }}.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm
|
|
||||||
yum install -y https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
|
|
||||||
yum install -y centos-release-scl
|
|
||||||
yum install -y devtoolset-11-gcc-c++ make git python3 nodejs fontconfig google-noto-sans-fonts
|
|
||||||
echo "/opt/rh/devtoolset-11/root/usr/bin" >> $GITHUB_PATH
|
|
||||||
- name: Dependencies (Rocky Linux glibc)
|
- name: Dependencies (Rocky Linux glibc)
|
||||||
if: contains(matrix.container, 'rockylinux')
|
if: contains(matrix.container, 'rockylinux')
|
||||||
run: |
|
run: |
|
||||||
dnf install -y https://rpm.nodesource.com/pub_${{ matrix.nodejs_version_major }}.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm
|
|
||||||
dnf install -y --setopt=nodesource-nodejs.module_hotfixes=1 nodejs
|
|
||||||
dnf install -y gcc-toolset-11-gcc-c++ make git python3 fontconfig google-noto-sans-fonts
|
dnf install -y gcc-toolset-11-gcc-c++ make git python3 fontconfig google-noto-sans-fonts
|
||||||
echo "/opt/rh/gcc-toolset-11/root/usr/bin" >> $GITHUB_PATH
|
echo "/opt/rh/gcc-toolset-11/root/usr/bin" >> $GITHUB_PATH
|
||||||
- name: Dependencies (Linux musl)
|
- name: Dependencies (Linux musl)
|
||||||
@@ -91,8 +83,8 @@ jobs:
|
|||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
- name: Dependencies (Node.js - macOS, Windows)
|
- name: Dependencies (Node.js)
|
||||||
if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
|
if: "!contains(matrix.platform, 'linuxmusl')"
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.nodejs_version }}
|
node-version: ${{ matrix.nodejs_version }}
|
||||||
@@ -166,7 +158,7 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
name: wasm32 - prebuild
|
name: wasm32 - prebuild
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
container: "emscripten/emsdk:3.1.48"
|
container: "emscripten/emsdk:3.1.51"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -178,6 +170,13 @@ jobs:
|
|||||||
node-version: "20"
|
node-version: "20"
|
||||||
- name: Install
|
- name: Install
|
||||||
run: emmake npm install --build-from-source
|
run: emmake npm install --build-from-source
|
||||||
|
- name: Verify emscripten versions match
|
||||||
|
run: |
|
||||||
|
EMSCRIPTEN_VERSION_LIBVIPS=$(node -p "require('@img/sharp-libvips-dev-wasm32/versions').emscripten")
|
||||||
|
EMSCRIPTEN_VERSION_SHARP=$(emcc -dumpversion)
|
||||||
|
echo "libvips built with emscripten $EMSCRIPTEN_VERSION_LIBVIPS"
|
||||||
|
echo "sharp built with emscripten $EMSCRIPTEN_VERSION_SHARP"
|
||||||
|
test "$EMSCRIPTEN_VERSION_LIBVIPS" = "$EMSCRIPTEN_VERSION_SHARP"
|
||||||
- name: Test
|
- name: Test
|
||||||
run: emmake npm test
|
run: emmake npm test
|
||||||
- name: Test packaging
|
- name: Test packaging
|
||||||
|
|||||||
24
.github/workflows/npm.yml
vendored
24
.github/workflows/npm.yml
vendored
@@ -27,6 +27,10 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
runtime: node
|
runtime: node
|
||||||
package-manager: yarn
|
package-manager: yarn
|
||||||
|
- name: linux-x64-node-yarn-pnp
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
runtime: node
|
||||||
|
package-manager: yarn-pnp
|
||||||
- name: linux-x64-deno
|
- name: linux-x64-deno
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
runtime: deno
|
runtime: deno
|
||||||
@@ -46,6 +50,10 @@ jobs:
|
|||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
runtime: node
|
runtime: node
|
||||||
package-manager: yarn
|
package-manager: yarn
|
||||||
|
- name: darwin-x64-node-yarn-pnp
|
||||||
|
runs-on: macos-11
|
||||||
|
runtime: node
|
||||||
|
package-manager: yarn-pnp
|
||||||
- name: darwin-x64-deno
|
- name: darwin-x64-deno
|
||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
runtime: deno
|
runtime: deno
|
||||||
@@ -65,6 +73,10 @@ jobs:
|
|||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
runtime: node
|
runtime: node
|
||||||
package-manager: yarn
|
package-manager: yarn
|
||||||
|
- name: win32-x64-node-yarn-pnp
|
||||||
|
runs-on: windows-2019
|
||||||
|
runtime: node
|
||||||
|
package-manager: yarn-pnp
|
||||||
- name: win32-x64-deno
|
- name: win32-x64-deno
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
runtime: deno
|
runtime: deno
|
||||||
@@ -115,35 +127,37 @@ jobs:
|
|||||||
contents: |
|
contents: |
|
||||||
import { deepStrictEqual } from 'node:assert';
|
import { deepStrictEqual } from 'node:assert';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
deepStrictEqual(['.jpg', '.jpeg', '.jpe'], sharp.format.jpeg.input.fileSuffix);
|
deepStrictEqual(['.jpg', '.jpeg', '.jpe', '.jfif'], sharp.format.jpeg.input.fileSuffix);
|
||||||
|
|
||||||
- name: Run with Node.js + npm
|
- name: Run with Node.js + npm
|
||||||
if: ${{ matrix.runtime == 'node' && matrix.package-manager == 'npm' }}
|
if: ${{ matrix.package-manager == 'npm' }}
|
||||||
run: |
|
run: |
|
||||||
npm install --ignore-scripts
|
npm install --ignore-scripts
|
||||||
node release.mjs
|
node release.mjs
|
||||||
|
|
||||||
- name: Run with Node.js + pnpm
|
- name: Run with Node.js + pnpm
|
||||||
if: ${{ matrix.runtime == 'node' && matrix.package-manager == 'pnpm' }}
|
if: ${{ matrix.package-manager == 'pnpm' }}
|
||||||
run: |
|
run: |
|
||||||
pnpm install --ignore-scripts
|
pnpm install --ignore-scripts
|
||||||
node release.mjs
|
node release.mjs
|
||||||
|
|
||||||
- name: Run with Node.js + yarn
|
- name: Run with Node.js + yarn
|
||||||
if: ${{ matrix.runtime == 'node' && matrix.package-manager == 'yarn' }}
|
if: ${{ matrix.package-manager == 'yarn' }}
|
||||||
run: |
|
run: |
|
||||||
corepack enable
|
corepack enable
|
||||||
yarn set version stable
|
yarn set version stable
|
||||||
|
yarn config set enableImmutableInstalls false
|
||||||
yarn config set enableScripts false
|
yarn config set enableScripts false
|
||||||
yarn config set nodeLinker node-modules
|
yarn config set nodeLinker node-modules
|
||||||
yarn install
|
yarn install
|
||||||
node release.mjs
|
node release.mjs
|
||||||
|
|
||||||
- name: Run with Node.js + yarn pnp
|
- name: Run with Node.js + yarn pnp
|
||||||
if: ${{ matrix.runtime == 'node' && matrix.package-manager == 'yarn' }}
|
if: ${{ matrix.package-manager == 'yarn-pnp' }}
|
||||||
run: |
|
run: |
|
||||||
corepack enable
|
corepack enable
|
||||||
yarn set version stable
|
yarn set version stable
|
||||||
|
yarn config set enableImmutableInstalls false
|
||||||
yarn config set enableScripts false
|
yarn config set enableScripts false
|
||||||
yarn config set nodeLinker pnp
|
yarn config set nodeLinker pnp
|
||||||
yarn install
|
yarn install
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions
|
|||||||
|
|
||||||
It can be used with all JavaScript runtimes
|
It can be used with all JavaScript runtimes
|
||||||
that provide support for Node-API v9, including
|
that provide support for Node-API v9, including
|
||||||
Node.js >= 18.17.0, Deno and Bun.
|
Node.js (^18.17.0 or >= 20.3.0), Deno and Bun.
|
||||||
|
|
||||||
Resizing an image is typically 4x-5x faster than using the
|
Resizing an image is typically 4x-5x faster than using the
|
||||||
quickest ImageMagick and GraphicsMagick settings
|
quickest ImageMagick and GraphicsMagick settings
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ The use of `rotate` without an angle will remove the EXIF `Orientation` tag, if
|
|||||||
Only one rotation can occur per pipeline.
|
Only one rotation can occur per pipeline.
|
||||||
Previous calls to `rotate` in the same pipeline will be ignored.
|
Previous calls to `rotate` in the same pipeline will be ignored.
|
||||||
|
|
||||||
|
Multi-page images can only be rotated by 180 degrees.
|
||||||
|
|
||||||
Method order is important when rotating, resizing and/or extracting regions,
|
Method order is important when rotating, resizing and/or extracting regions,
|
||||||
for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
|
for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,21 @@
|
|||||||
|
|
||||||
## v0.33 - *gauge*
|
## v0.33 - *gauge*
|
||||||
|
|
||||||
Requires libvips v8.15.0
|
Requires libvips v8.15.1
|
||||||
|
|
||||||
### v0.33.1 - TBD
|
### v0.33.2 - 12th January 2024
|
||||||
|
|
||||||
|
* TypeScript: add definition for `keepMetadata`.
|
||||||
|
[#3914](https://github.com/lovell/sharp/pull/3914)
|
||||||
|
[@abhi0498](https://github.com/abhi0498)
|
||||||
|
|
||||||
|
* Ensure `extend` operation stays sequential when copying (regression in 0.32.0).
|
||||||
|
[#3928](https://github.com/lovell/sharp/issues/3928)
|
||||||
|
|
||||||
|
* Improve error handling for unsupported multi-page rotation.
|
||||||
|
[#3940](https://github.com/lovell/sharp/issues/3940)
|
||||||
|
|
||||||
|
### v0.33.1 - 17th December 2023
|
||||||
|
|
||||||
* Add support for Yarn Plug'n'Play filesystem layout.
|
* Add support for Yarn Plug'n'Play filesystem layout.
|
||||||
[#3888](https://github.com/lovell/sharp/issues/3888)
|
[#3888](https://github.com/lovell/sharp/issues/3888)
|
||||||
@@ -18,7 +30,7 @@ Requires libvips v8.15.0
|
|||||||
|
|
||||||
### v0.33.0 - 29th November 2023
|
### v0.33.0 - 29th November 2023
|
||||||
|
|
||||||
* Drop support for Node.js 14 and 16, now requires Node.js >= 18.17.0
|
* Drop support for Node.js 14 and 16, now requires Node.js ^18.17.0 or >= 20.3.0
|
||||||
|
|
||||||
* Prebuilt binaries distributed via npm registry and installed via package manager.
|
* Prebuilt binaries distributed via npm registry and installed via package manager.
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ deno run --allow-ffi ...
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
* Node-API v9 compatible runtime e.g. Node.js >= 18.17.0
|
* Node-API v9 compatible runtime e.g. Node.js ^18.17.0 or >=20.3.0.
|
||||||
|
|
||||||
## Prebuilt binaries
|
## Prebuilt binaries
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ for the current OS platform and CPU architecture, where available.
|
|||||||
Some package managers support multiple platforms and architectures
|
Some package managers support multiple platforms and architectures
|
||||||
within the same installation tree and/or using the same lockfile.
|
within the same installation tree and/or using the same lockfile.
|
||||||
|
|
||||||
### npm
|
### npm v10+
|
||||||
|
|
||||||
> ⚠️ **npm `package-lock.json` files can cause installation problems due to [npm bug #4828](https://github.com/npm/cli/issues/4828)**
|
> ⚠️ **npm `package-lock.json` files can cause installation problems due to [npm bug #4828](https://github.com/npm/cli/issues/4828)**
|
||||||
|
|
||||||
@@ -79,11 +79,11 @@ npm install --cpu=x64 --os=linux sharp
|
|||||||
npm install --cpu=x64 --os=linux --libc=musl sharp
|
npm install --cpu=x64 --os=linux --libc=musl sharp
|
||||||
```
|
```
|
||||||
|
|
||||||
### yarn
|
### yarn v3+
|
||||||
|
|
||||||
Use the [supportedArchitectures](https://yarnpkg.com/configuration/yarnrc#supportedArchitectures) configuration.
|
Use the [supportedArchitectures](https://yarnpkg.com/configuration/yarnrc#supportedArchitectures) configuration.
|
||||||
|
|
||||||
### pnpm
|
### pnpm v8+
|
||||||
|
|
||||||
Use the [supportedArchitectures](https://pnpm.io/package_json#pnpmsupportedarchitectures) configuration.
|
Use the [supportedArchitectures](https://pnpm.io/package_json#pnpmsupportedarchitectures) configuration.
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ This module will be compiled from source at `npm install` time when:
|
|||||||
Building from source requires:
|
Building from source requires:
|
||||||
|
|
||||||
* C++11 compiler
|
* C++11 compiler
|
||||||
* [node-addon-api](https://www.npmjs.com/package/node-addon-api)
|
* [node-addon-api](https://www.npmjs.com/package/node-addon-api) version 7+
|
||||||
* [node-gyp](https://github.com/nodejs/node-gyp#installation) and its dependencies
|
* [node-gyp](https://github.com/nodejs/node-gyp#installation) version 9+ and its dependencies
|
||||||
|
|
||||||
There is an install-time check for these dependencies.
|
There is an install-time check for these dependencies.
|
||||||
If `node-addon-api` or `node-gyp` cannot be found, try adding them via:
|
If `node-addon-api` or `node-gyp` cannot be found, try adding them via:
|
||||||
@@ -173,25 +173,11 @@ must include binaries for either the linux-x64 or linux-arm64 platforms
|
|||||||
depending on the chosen architecture.
|
depending on the chosen architecture.
|
||||||
|
|
||||||
When building your deployment package on a machine that differs from the target architecture,
|
When building your deployment package on a machine that differs from the target architecture,
|
||||||
you will need to install either `@img/sharp-linux-x64` or `@img/sharp-linux-arm64` package.
|
see the [cross-platform](#cross-platform) section to help decide which package manager is appropriate
|
||||||
|
and how to configure it.
|
||||||
|
|
||||||
```sh
|
Some package managers use symbolic links
|
||||||
npm install --os=linux --cpu=x64 sharp
|
but AWS Lambda does not support these within deployment packages.
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --os=linux --cpu=arm64 sharp
|
|
||||||
```
|
|
||||||
|
|
||||||
When using npm 9 or earlier, this can be achieved using the following:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --force @img/sharp-linux-x64
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --force @img/sharp-linux-arm64
|
|
||||||
```
|
|
||||||
|
|
||||||
To get the best performance select the largest memory available.
|
To get the best performance select the largest memory available.
|
||||||
A 1536 MB function provides ~12x more CPU time than a 128 MB function.
|
A 1536 MB function provides ~12x more CPU time than a 128 MB function.
|
||||||
@@ -245,6 +231,24 @@ custom:
|
|||||||
- npm install --os=linux --cpu=x64 sharp
|
- npm install --os=linux --cpu=x64 sharp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### electron
|
||||||
|
|
||||||
|
Ensure `sharp` is unpacked from the ASAR archive file using the
|
||||||
|
[asarUnpack](https://www.electron.build/configuration/configuration.html)
|
||||||
|
option.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"asar": true,
|
||||||
|
"asarUnpack": [
|
||||||
|
"**/node_modules/sharp/**/*",
|
||||||
|
"**/node_modules/@img/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## TypeScript
|
## TypeScript
|
||||||
|
|
||||||
TypeScript definitions are published as part of
|
TypeScript definitions are published as part of
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
6
lib/index.d.ts
vendored
6
lib/index.d.ts
vendored
@@ -341,6 +341,12 @@ declare namespace sharp {
|
|||||||
*/
|
*/
|
||||||
metadata(): Promise<Metadata>;
|
metadata(): Promise<Metadata>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.
|
||||||
|
* @returns A sharp instance that can be used to chain operations
|
||||||
|
*/
|
||||||
|
keepMetadata(): Sharp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to pixel-derived image statistics for every channel in the image.
|
* Access to pixel-derived image statistics for every channel in the image.
|
||||||
* @returns A sharp instance that can be used to chain operations
|
* @returns A sharp instance that can be used to chain operations
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const { spawnSync } = require('node:child_process');
|
|||||||
const { createHash } = require('node:crypto');
|
const { createHash } = require('node:crypto');
|
||||||
const semverCoerce = require('semver/functions/coerce');
|
const semverCoerce = require('semver/functions/coerce');
|
||||||
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
|
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
|
||||||
|
const semverSatisfies = require('semver/functions/satisfies');
|
||||||
const detectLibc = require('detect-libc');
|
const detectLibc = require('detect-libc');
|
||||||
|
|
||||||
const { engines, optionalDependencies } = require('../package.json');
|
const { engines, optionalDependencies } = require('../package.json');
|
||||||
@@ -83,6 +84,15 @@ const buildSharpLibvipsLibDir = () => {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isUnsupportedNodeRuntime = () => {
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (process.release?.name === 'node' && process.versions) {
|
||||||
|
if (!semverSatisfies(process.versions.node, engines.node)) {
|
||||||
|
return { found: process.versions.node, expected: engines.node };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
const isEmscripten = () => {
|
const isEmscripten = () => {
|
||||||
const { CC } = process.env;
|
const { CC } = process.env;
|
||||||
@@ -174,6 +184,7 @@ module.exports = {
|
|||||||
buildSharpLibvipsIncludeDir,
|
buildSharpLibvipsIncludeDir,
|
||||||
buildSharpLibvipsCPlusPlusDir,
|
buildSharpLibvipsCPlusPlusDir,
|
||||||
buildSharpLibvipsLibDir,
|
buildSharpLibvipsLibDir,
|
||||||
|
isUnsupportedNodeRuntime,
|
||||||
runtimePlatformArch,
|
runtimePlatformArch,
|
||||||
log,
|
log,
|
||||||
yarnLocator,
|
yarnLocator,
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ const is = require('./is');
|
|||||||
* Only one rotation can occur per pipeline.
|
* Only one rotation can occur per pipeline.
|
||||||
* Previous calls to `rotate` in the same pipeline will be ignored.
|
* Previous calls to `rotate` in the same pipeline will be ignored.
|
||||||
*
|
*
|
||||||
|
* Multi-page images can only be rotated by 180 degrees.
|
||||||
|
*
|
||||||
* Method order is important when rotating, resizing and/or extracting regions,
|
* Method order is important when rotating, resizing and/or extracting regions,
|
||||||
* for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
|
* for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
|
||||||
*
|
*
|
||||||
|
|||||||
17
lib/sharp.js
17
lib/sharp.js
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
const { familySync, versionSync } = require('detect-libc');
|
const { familySync, versionSync } = require('detect-libc');
|
||||||
|
|
||||||
const { runtimePlatformArch, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
|
const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
|
||||||
const runtimePlatform = runtimePlatformArch();
|
const runtimePlatform = runtimePlatformArch();
|
||||||
|
|
||||||
const paths = [
|
const paths = [
|
||||||
@@ -44,8 +44,16 @@ if (sharp) {
|
|||||||
const messages = errors.map(err => err.message).join(' ');
|
const messages = errors.map(err => err.message).join(' ');
|
||||||
help.push('Possible solutions:');
|
help.push('Possible solutions:');
|
||||||
// Common error messages
|
// Common error messages
|
||||||
if (prebuiltPlatforms.includes(runtimePlatform)) {
|
if (isUnsupportedNodeRuntime()) {
|
||||||
|
const { found, expected } = isUnsupportedNodeRuntime();
|
||||||
|
help.push(
|
||||||
|
'- Please upgrade Node.js:',
|
||||||
|
` Found ${found}`,
|
||||||
|
` Requires ${expected}`
|
||||||
|
);
|
||||||
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
||||||
const [os, cpu] = runtimePlatform.split('-');
|
const [os, cpu] = runtimePlatform.split('-');
|
||||||
|
const libc = os.endsWith('musl') ? ' --libc=musl' : '';
|
||||||
help.push(
|
help.push(
|
||||||
'- Ensure optional dependencies can be installed:',
|
'- Ensure optional dependencies can be installed:',
|
||||||
' npm install --include=optional sharp',
|
' npm install --include=optional sharp',
|
||||||
@@ -53,15 +61,14 @@ if (sharp) {
|
|||||||
'- Ensure your package manager supports multi-platform installation:',
|
'- Ensure your package manager supports multi-platform installation:',
|
||||||
' See https://sharp.pixelplumbing.com/install#cross-platform',
|
' See https://sharp.pixelplumbing.com/install#cross-platform',
|
||||||
'- Add platform-specific dependencies:',
|
'- Add platform-specific dependencies:',
|
||||||
` npm install --os=${os} --cpu=${cpu} sharp`,
|
` npm install --os=${os.replace('musl', '')}${libc} --cpu=${cpu} sharp`
|
||||||
` npm install --force @img/sharp-${runtimePlatform}`
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
help.push(
|
help.push(
|
||||||
`- Manually install libvips >= ${minimumLibvipsVersion}`,
|
`- Manually install libvips >= ${minimumLibvipsVersion}`,
|
||||||
'- Add experimental WebAssembly-based dependencies:',
|
'- Add experimental WebAssembly-based dependencies:',
|
||||||
' npm install --cpu=wasm32 sharp',
|
' npm install --cpu=wasm32 sharp',
|
||||||
' npm install --force @img/sharp-wasm32'
|
' npm install @img/sharp-wasm32'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
|
if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-darwin-arm64",
|
"name": "@img/sharp-darwin-arm64",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-darwin-arm64": "1.0.0"
|
"@img/sharp-libvips-darwin-arm64": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-darwin-x64",
|
"name": "@img/sharp-darwin-x64",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-darwin-x64": "1.0.0"
|
"@img/sharp-libvips-darwin-x64": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-arm",
|
"name": "@img/sharp-linux-arm",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-arm": "1.0.0"
|
"@img/sharp-libvips-linux-arm": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-arm64",
|
"name": "@img/sharp-linux-arm64",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-arm64": "1.0.0"
|
"@img/sharp-libvips-linux-arm64": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-s390x",
|
"name": "@img/sharp-linux-s390x",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-s390x": "1.0.0"
|
"@img/sharp-libvips-linux-s390x": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-x64",
|
"name": "@img/sharp-linux-x64",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-x64": "1.0.0"
|
"@img/sharp-libvips-linux-x64": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linuxmusl-arm64",
|
"name": "@img/sharp-linuxmusl-arm64",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linuxmusl-arm64": "1.0.0"
|
"@img/sharp-libvips-linuxmusl-arm64": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linuxmusl-x64",
|
"name": "@img/sharp-linuxmusl-x64",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linuxmusl-x64": "1.0.0"
|
"@img/sharp-libvips-linuxmusl-x64": "1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp",
|
"name": "@img/sharp",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"darwin-arm64",
|
"darwin-arm64",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-wasm32",
|
"name": "@img/sharp-wasm32",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"pnpm": ">=7.1.0"
|
"pnpm": ">=7.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emnapi/runtime": "^0.44.0"
|
"@emnapi/runtime": "^0.45.0"
|
||||||
},
|
},
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-win32-ia32",
|
"name": "@img/sharp-win32-ia32",
|
||||||
"version": "0.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"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",
|
||||||
|
|||||||
58
package.json
58
package.json
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"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.33.1-rc.1",
|
"version": "0.33.2",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://github.com/lovell/sharp",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Pierre Inglebert <pierre.inglebert@gmail.com>",
|
"Pierre Inglebert <pierre.inglebert@gmail.com>",
|
||||||
"Jonathan Ong <jonathanrichardong@gmail.com>",
|
"Jonathan Ong <jonathanrichardong@gmail.com>",
|
||||||
@@ -141,36 +141,36 @@
|
|||||||
"semver": "^7.5.4"
|
"semver": "^7.5.4"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-darwin-arm64": "0.33.1-rc.1",
|
"@img/sharp-darwin-arm64": "0.33.2",
|
||||||
"@img/sharp-darwin-x64": "0.33.1-rc.1",
|
"@img/sharp-darwin-x64": "0.33.2",
|
||||||
"@img/sharp-libvips-darwin-arm64": "1.0.0",
|
"@img/sharp-libvips-darwin-arm64": "1.0.1",
|
||||||
"@img/sharp-libvips-darwin-x64": "1.0.0",
|
"@img/sharp-libvips-darwin-x64": "1.0.1",
|
||||||
"@img/sharp-libvips-linux-arm": "1.0.0",
|
"@img/sharp-libvips-linux-arm": "1.0.1",
|
||||||
"@img/sharp-libvips-linux-arm64": "1.0.0",
|
"@img/sharp-libvips-linux-arm64": "1.0.1",
|
||||||
"@img/sharp-libvips-linux-s390x": "1.0.0",
|
"@img/sharp-libvips-linux-s390x": "1.0.1",
|
||||||
"@img/sharp-libvips-linux-x64": "1.0.0",
|
"@img/sharp-libvips-linux-x64": "1.0.1",
|
||||||
"@img/sharp-libvips-linuxmusl-arm64": "1.0.0",
|
"@img/sharp-libvips-linuxmusl-arm64": "1.0.1",
|
||||||
"@img/sharp-libvips-linuxmusl-x64": "1.0.0",
|
"@img/sharp-libvips-linuxmusl-x64": "1.0.1",
|
||||||
"@img/sharp-linux-arm": "0.33.1-rc.1",
|
"@img/sharp-linux-arm": "0.33.2",
|
||||||
"@img/sharp-linux-arm64": "0.33.1-rc.1",
|
"@img/sharp-linux-arm64": "0.33.2",
|
||||||
"@img/sharp-linux-s390x": "0.33.1-rc.1",
|
"@img/sharp-linux-s390x": "0.33.2",
|
||||||
"@img/sharp-linux-x64": "0.33.1-rc.1",
|
"@img/sharp-linux-x64": "0.33.2",
|
||||||
"@img/sharp-linuxmusl-arm64": "0.33.1-rc.1",
|
"@img/sharp-linuxmusl-arm64": "0.33.2",
|
||||||
"@img/sharp-linuxmusl-x64": "0.33.1-rc.1",
|
"@img/sharp-linuxmusl-x64": "0.33.2",
|
||||||
"@img/sharp-wasm32": "0.33.1-rc.1",
|
"@img/sharp-wasm32": "0.33.2",
|
||||||
"@img/sharp-win32-ia32": "0.33.1-rc.1",
|
"@img/sharp-win32-ia32": "0.33.2",
|
||||||
"@img/sharp-win32-x64": "0.33.1-rc.1"
|
"@img/sharp-win32-x64": "0.33.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emnapi/runtime": "^0.44.0",
|
"@emnapi/runtime": "^0.45.0",
|
||||||
"@img/sharp-libvips-dev": "1.0.0",
|
"@img/sharp-libvips-dev": "1.0.1",
|
||||||
"@img/sharp-libvips-dev-wasm32": "1.0.0",
|
"@img/sharp-libvips-dev-wasm32": "1.0.1",
|
||||||
"@img/sharp-libvips-win32-ia32": "1.0.0",
|
"@img/sharp-libvips-win32-ia32": "1.0.1",
|
||||||
"@img/sharp-libvips-win32-x64": "1.0.0",
|
"@img/sharp-libvips-win32-x64": "1.0.1",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"async": "^3.2.5",
|
"async": "^3.2.5",
|
||||||
"cc": "^3.0.1",
|
"cc": "^3.0.1",
|
||||||
"emnapi": "^0.44.0",
|
"emnapi": "^0.45.0",
|
||||||
"exif-reader": "^2.0.0",
|
"exif-reader": "^2.0.0",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"icc": "^3.0.0",
|
"icc": "^3.0.0",
|
||||||
@@ -182,12 +182,12 @@
|
|||||||
"prebuild": "^12.1.0",
|
"prebuild": "^12.1.0",
|
||||||
"semistandard": "^17.0.0",
|
"semistandard": "^17.0.0",
|
||||||
"tar-fs": "^3.0.4",
|
"tar-fs": "^3.0.4",
|
||||||
"tsd": "^0.29.0"
|
"tsd": "^0.30.3"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
|
||||||
"libvips": ">=8.15.0"
|
"libvips": ">=8.15.1"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://opencollective.com/libvips"
|
"url": "https://opencollective.com/libvips"
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
#if (VIPS_MAJOR_VERSION < 8) || \
|
#if (VIPS_MAJOR_VERSION < 8) || \
|
||||||
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 15) || \
|
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 15) || \
|
||||||
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 15 && VIPS_MICRO_VERSION < 0)
|
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 15 && VIPS_MICRO_VERSION < 1)
|
||||||
#error "libvips version 8.15.0+ is required - please see https://sharp.pixelplumbing.com/install"
|
#error "libvips version 8.15.1+ is required - please see https://sharp.pixelplumbing.com/install"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
baton->rotationAngle != 0.0);
|
baton->rotationAngle != 0.0);
|
||||||
|
|
||||||
if (autoRotation != VIPS_ANGLE_D0) {
|
if (autoRotation != VIPS_ANGLE_D0) {
|
||||||
|
if (autoRotation != VIPS_ANGLE_D180) {
|
||||||
|
MultiPageUnsupported(nPages, "Rotate");
|
||||||
|
}
|
||||||
image = image.rot(autoRotation);
|
image = image.rot(autoRotation);
|
||||||
autoRotation = VIPS_ANGLE_D0;
|
autoRotation = VIPS_ANGLE_D0;
|
||||||
}
|
}
|
||||||
@@ -114,6 +117,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
baton->flop = FALSE;
|
baton->flop = FALSE;
|
||||||
}
|
}
|
||||||
if (rotation != VIPS_ANGLE_D0) {
|
if (rotation != VIPS_ANGLE_D0) {
|
||||||
|
if (rotation != VIPS_ANGLE_D180) {
|
||||||
|
MultiPageUnsupported(nPages, "Rotate");
|
||||||
|
}
|
||||||
image = image.rot(rotation);
|
image = image.rot(rotation);
|
||||||
rotation = VIPS_ANGLE_D0;
|
rotation = VIPS_ANGLE_D0;
|
||||||
}
|
}
|
||||||
@@ -397,6 +403,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
rotation != VIPS_ANGLE_D0);
|
rotation != VIPS_ANGLE_D0);
|
||||||
// Auto-rotate post-extract
|
// Auto-rotate post-extract
|
||||||
if (autoRotation != VIPS_ANGLE_D0) {
|
if (autoRotation != VIPS_ANGLE_D0) {
|
||||||
|
if (autoRotation != VIPS_ANGLE_D180) {
|
||||||
|
MultiPageUnsupported(nPages, "Rotate");
|
||||||
|
}
|
||||||
image = image.rot(autoRotation);
|
image = image.rot(autoRotation);
|
||||||
}
|
}
|
||||||
// Mirror vertically (up-down) about the x-axis
|
// Mirror vertically (up-down) about the x-axis
|
||||||
@@ -409,6 +418,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
}
|
}
|
||||||
// Rotate post-extract 90-angle
|
// Rotate post-extract 90-angle
|
||||||
if (rotation != VIPS_ANGLE_D0) {
|
if (rotation != VIPS_ANGLE_D0) {
|
||||||
|
if (rotation != VIPS_ANGLE_D180) {
|
||||||
|
MultiPageUnsupported(nPages, "Rotate");
|
||||||
|
}
|
||||||
image = image.rot(rotation);
|
image = image.rot(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,6 +573,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
VImage::option()->set("extend", baton->extendWith)->set("background", background));
|
VImage::option()->set("extend", baton->extendWith)->set("background", background));
|
||||||
} else {
|
} else {
|
||||||
std::vector<double> ignoredBackground(1);
|
std::vector<double> ignoredBackground(1);
|
||||||
|
image = sharp::StaySequential(image, baton->input->access);
|
||||||
image = nPages > 1
|
image = nPages > 1
|
||||||
? sharp::EmbedMultiPage(image,
|
? sharp::EmbedMultiPage(image,
|
||||||
baton->extendLeft, baton->extendTop, baton->width, baton->height,
|
baton->extendLeft, baton->extendTop, baton->width, baton->height,
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ sharp('input.png')
|
|||||||
// sharpened, with metadata, 90% quality WebP image data. Phew!
|
// sharpened, with metadata, 90% quality WebP image data. Phew!
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sharp('input.png')
|
||||||
|
.keepMetadata()
|
||||||
|
.toFile('output.png', (err, info) => {
|
||||||
|
// output.png is an image containing input.png along with all metadata(EXIF, ICC, XMP, IPTC) from input.png
|
||||||
|
})
|
||||||
|
|
||||||
sharp('input.jpg')
|
sharp('input.jpg')
|
||||||
.resize(300, 200)
|
.resize(300, 200)
|
||||||
.toFile('output.jpg', (err: Error) => {
|
.toFile('output.jpg', (err: Error) => {
|
||||||
|
|||||||
@@ -73,6 +73,20 @@ describe('Extend', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('extend top with mirroring uses ordered read', async () => {
|
||||||
|
const data = await sharp(fixtures.inputJpg)
|
||||||
|
.extend({
|
||||||
|
extendWith: 'mirror',
|
||||||
|
top: 1
|
||||||
|
})
|
||||||
|
.png({ compressionLevel: 0 })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const { width, height } = await sharp(data).metadata();
|
||||||
|
assert.strictEqual(2725, width);
|
||||||
|
assert.strictEqual(2226, height);
|
||||||
|
});
|
||||||
|
|
||||||
it(`extend sides unequally with RGBA (${extendWith})`, function (done) {
|
it(`extend sides unequally with RGBA (${extendWith})`, function (done) {
|
||||||
sharp(fixtures.inputPngWithTransparency16bit)
|
sharp(fixtures.inputPngWithTransparency16bit)
|
||||||
.resize(120)
|
.resize(120)
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ describe('libvips binaries', function () {
|
|||||||
const [, arch] = libvips.runtimePlatformArch().split('-');
|
const [, arch] = libvips.runtimePlatformArch().split('-');
|
||||||
assert.strict(['arm', 'arm64', 'ia32', 'x64'].includes(arch));
|
assert.strict(['arm', 'arm64', 'ia32', 'x64'].includes(arch));
|
||||||
});
|
});
|
||||||
|
it('isUnsupportedNodeRuntime', () => {
|
||||||
|
assert.strictEqual(libvips.isUnsupportedNodeRuntime(), undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('logger', function () {
|
describe('logger', function () {
|
||||||
@@ -159,7 +162,7 @@ describe('libvips binaries', function () {
|
|||||||
process.env.npm_config_arch = 's390x';
|
process.env.npm_config_arch = 's390x';
|
||||||
process.env.npm_config_libc = '';
|
process.env.npm_config_libc = '';
|
||||||
const locatorHash = libvips.yarnLocator();
|
const locatorHash = libvips.yarnLocator();
|
||||||
assert.strictEqual(locatorHash, '86cc8ee6e4');
|
assert.strictEqual(locatorHash, 'f2bd19138a');
|
||||||
delete process.env.npm_config_platform;
|
delete process.env.npm_config_platform;
|
||||||
delete process.env.npm_config_arch;
|
delete process.env.npm_config_arch;
|
||||||
delete process.env.npm_config_libc;
|
delete process.env.npm_config_libc;
|
||||||
|
|||||||
@@ -353,6 +353,21 @@ describe('Rotation', function () {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('Animated image rotate 180', () =>
|
||||||
|
assert.doesNotReject(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||||
|
.rotate(180)
|
||||||
|
.toBuffer()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
it('Animated image rotate non-180 rejects', () =>
|
||||||
|
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||||
|
.rotate(90)
|
||||||
|
.toBuffer(),
|
||||||
|
/Rotate is not supported for multi-page images/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
it('Multiple rotate emits warning', () => {
|
it('Multiple rotate emits warning', () => {
|
||||||
let warningMessage = '';
|
let warningMessage = '';
|
||||||
const s = sharp();
|
const s = sharp();
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ describe('Utilities', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('input fileSuffix', function () {
|
it('input fileSuffix', function () {
|
||||||
assert.deepStrictEqual(['.jpg', '.jpeg', '.jpe'], sharp.format.jpeg.input.fileSuffix);
|
assert.deepStrictEqual(['.jpg', '.jpeg', '.jpe', '.jfif'], sharp.format.jpeg.input.fileSuffix);
|
||||||
});
|
});
|
||||||
it('output alias', function () {
|
it('output alias', function () {
|
||||||
assert.deepStrictEqual(['jpe', 'jpg'], sharp.format.jpeg.output.alias);
|
assert.deepStrictEqual(['jpe', 'jpg'], sharp.format.jpeg.output.alias);
|
||||||
|
|||||||
Reference in New Issue
Block a user