Compare commits

...

17 Commits

Author SHA1 Message Date
Lovell Fuller
4919bc5134 Release v0.33.1 2023-12-17 20:10:30 +00:00
Lovell Fuller
a4e64eb01f Prerelease v0.33.1-rc.3 2023-12-17 19:32:36 +00:00
Lovell Fuller
328b18df88 CI: Split yarn pnp package tests into separate jobs 2023-12-17 19:00:14 +00:00
Lovell Fuller
5e7bf32e5e Docs: refresh index and homepage link 2023-12-17 18:51:49 +00:00
Lovell Fuller
04403f4e5f Prerelease v0.33.1-rc.2 2023-12-17 17:13:34 +00:00
Lovell Fuller
420e0822b4 CI: Pin Node.js 18 to avoid npm 10 on 32-bit Windows
npm 10 seems to be opening thousands of network connections,
leading to resource starvation in Node.js 18. This does not
appear to impact Node.js 20.
2023-12-17 16:53:12 +00:00
Lovell Fuller
f7a3ea6415 Prerelease v0.33.1-rc.1 2023-12-17 10:35:27 +00:00
Lovell Fuller
f28e79ef4f Improve resilience of installation check 2023-12-17 09:46:28 +00:00
Lovell Fuller
5cd787bf85 CI: Upgrade to latest FreeBSD, improve test resilience 2023-12-17 09:39:05 +00:00
Lovell Fuller
021d637fd6 Docs: changelog and credit for #3897 2023-12-15 19:08:14 +00:00
Tamás András Horváth
2e14096af7 Ensure VIPS_NOVECTOR env var is respected (#3897) 2023-12-15 18:51:32 +00:00
Lovell Fuller
fe2b298a2f Emit warning for invalid ICC profile #3895 2023-12-15 12:13:57 +00:00
Lovell Fuller
c9e3996007 Tests: attempt to reduce chance of race condition 2023-12-13 13:22:59 +00:00
Lovell Fuller
3a0c375692 Docs: improve cross-platform help messaging
tldr; don't use npm for multi-platform installs
2023-12-13 12:59:14 +00:00
Lovell Fuller
c5eaeb2ddb Add help when possibly using an unsupported libc 2023-12-12 21:01:09 +00:00
Lovell Fuller
19fa4cd1d3 Docs: update liborc references to highway 2023-12-12 12:01:41 +00:00
Lovell Fuller
0adf7ef16f CI: Ensure Yarn pnp linker uses ESM 2023-12-12 12:01:11 +00:00
31 changed files with 171 additions and 102 deletions

View File

@@ -1,5 +1,5 @@
freebsd_instance: freebsd_instance:
image_family: freebsd-13-2 image_family: freebsd-14-0-snap
task: task:
name: FreeBSD name: FreeBSD
@@ -10,7 +10,8 @@ task:
- pkg update -f - pkg update -f
- pkg upgrade -y - pkg upgrade -y
- pkg install -y devel/git devel/pkgconf graphics/vips www/node20 www/npm - pkg install -y devel/git devel/pkgconf graphics/vips www/node20 www/npm
- pkg-config --modversion vips-cpp
install_script: install_script:
- npm install --build-from-source - npm install --build-from-source
test_script: test_script:
- npm test - npx mocha --no-config --spec=test/unit/io.js --timeout=30000

View File

@@ -11,7 +11,10 @@ labels: installation
<!-- Please place an [x] in the box to confirm. --> <!-- Please place an [x] in the box to confirm. -->
- [ ] I have read the [documentation relating to installation](https://sharp.pixelplumbing.com/install). - [ ] I have read and understood all of the [documentation relating to installation](https://sharp.pixelplumbing.com/install).
- [ ] I have searched for known bugs relating to this problem in my choice of package manager.
You must confirm both of these before continuing.
### Are you using the latest version of sharp? ### Are you using the latest version of sharp?
@@ -47,7 +50,7 @@ and try again before opening an issue.
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 dependencies and ensure you are allowing the installation of optional or multi-platform dependencies
before opening an issue. before opening an issue.
### 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?

View File

@@ -47,7 +47,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

View File

@@ -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
@@ -105,7 +117,8 @@ jobs:
{ {
"dependencies": { "dependencies": {
"sharp": "${{ steps.version.outputs.semver }}" "sharp": "${{ steps.version.outputs.semver }}"
} },
"type": "module"
} }
- name: Create release.mjs - name: Create release.mjs
uses: DamianReeves/write-file-action@v1.2 uses: DamianReeves/write-file-action@v1.2
@@ -117,19 +130,19 @@ jobs:
deepStrictEqual(['.jpg', '.jpeg', '.jpe'], sharp.format.jpeg.input.fileSuffix); deepStrictEqual(['.jpg', '.jpeg', '.jpe'], 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
@@ -140,7 +153,7 @@ jobs:
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
@@ -148,7 +161,7 @@ jobs:
yarn config set enableScripts false yarn config set enableScripts false
yarn config set nodeLinker pnp yarn config set nodeLinker pnp
yarn install yarn install
node release.mjs yarn node release.mjs
- name: Run with Deno - name: Run with Deno
if: ${{ matrix.runtime == 'deno' }} if: ${{ matrix.runtime == 'deno' }}

View File

@@ -151,7 +151,7 @@ const counters = sharp.counters(); // { queue: 2, process: 4 }
> simd([simd]) ⇒ <code>boolean</code> > simd([simd]) ⇒ <code>boolean</code>
Get and set use of SIMD vector unit instructions. Get and set use of SIMD vector unit instructions.
Requires libvips to have been compiled with liborc support. Requires libvips to have been compiled with highway support.
Improves the performance of `resize`, `blur` and `sharpen` operations Improves the performance of `resize`, `blur` and `sharpen` operations
by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON. by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
@@ -165,12 +165,12 @@ by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM N
**Example** **Example**
```js ```js
const simd = sharp.simd(); const simd = sharp.simd();
// simd is `true` if the runtime use of liborc is currently enabled // simd is `true` if the runtime use of highway is currently enabled
``` ```
**Example** **Example**
```js ```js
const simd = sharp.simd(false); const simd = sharp.simd(false);
// prevent libvips from using liborc at runtime // prevent libvips from using highway at runtime
``` ```

View File

@@ -4,11 +4,18 @@
Requires libvips v8.15.0 Requires libvips v8.15.0
### v0.33.1 - TBD ### 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)
* Emit warning when attempting to use invalid ICC profiles.
[#3895](https://github.com/lovell/sharp/issues/3895)
* Ensure `VIPS_NOVECTOR` environment variable is respected.
[#3897](https://github.com/lovell/sharp/pull/3897)
[@icetee](https://github.com/icetee)
### 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

View File

@@ -281,3 +281,6 @@ GitHub: https://github.com/dnsbty
Name: Ingvar Stepanyan Name: Ingvar Stepanyan
GitHub: https://github.com/RReverser GitHub: https://github.com/RReverser
Name: Tamás András Horváth
GitHub: https://github.com/icetee

View File

@@ -4,6 +4,10 @@ Works with your choice of JavaScript package manager.
> ⚠️ **Please ensure your package manager is configured to install optional dependencies** > ⚠️ **Please ensure your package manager is configured to install optional dependencies**
If a package manager lockfile must support multiple platforms,
please see the [cross-platform](#cross-platform) section
to help decide which package manager is appropriate.
```sh ```sh
npm install sharp npm install sharp
``` ```
@@ -51,17 +55,21 @@ JPEG, PNG, WebP, AVIF (limited to 8-bit depth), TIFF, GIF and SVG (input) image
## Cross-platform ## Cross-platform
At install time, package managers will automatically select prebuilt binaries for the current OS platform and CPU architecture, where available. At install time, package managers will automatically select prebuilt binaries
for the current OS platform and CPU architecture, where available.
Some package managers support multiple platforms and architectures within the same installation tree. Some package managers support multiple platforms and architectures
within the same installation tree and/or using the same lockfile.
### npm ### npm
Use the `--os`, `--cpu` and `--libc` flags: > ⚠️ **npm `package-lock.json` files can cause installation problems due to [npm bug #4828](https://github.com/npm/cli/issues/4828)**
Provides limited support via `--os`, `--cpu` and `--libc` flags.
Example to support both Intel and ARM CPUs on macOS: Example to support both Intel and ARM CPUs on macOS:
```sh ```sh
npm install --cpu=x64 --os=darwin sharp npm install --cpu=x64 --os=darwin sharp
npm install --cpu=arm64 --os=darwin sharp npm install --cpu=arm64 --os=darwin sharp
``` ```

File diff suppressed because one or more lines are too long

View File

@@ -3,34 +3,39 @@
'use strict'; 'use strict';
const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips'); try {
const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
const buildFromSource = (msg) => { const buildFromSource = (msg) => {
log(msg); log(msg);
log('Attempting to build from source via node-gyp'); log('Attempting to build from source via node-gyp');
try { try {
require('node-addon-api'); require('node-addon-api');
log('Found node-addon-api'); log('Found node-addon-api');
} catch (err) { } catch (err) {
log('Please add node-addon-api to your dependencies'); log('Please add node-addon-api to your dependencies');
return; return;
} }
try { try {
const gyp = require('node-gyp'); const gyp = require('node-gyp');
log(`Found node-gyp version ${gyp().version}`); log(`Found node-gyp version ${gyp().version}`);
} catch (err) { } catch (err) {
log('Please add node-gyp to your dependencies'); log('Please add node-gyp to your dependencies');
return; return;
} }
log('See https://sharp.pixelplumbing.com/install#building-from-source'); log('See https://sharp.pixelplumbing.com/install#building-from-source');
const status = spawnRebuild(); const status = spawnRebuild();
if (status !== 0) { if (status !== 0) {
process.exit(status); process.exit(status);
} }
}; };
if (useGlobalLibvips()) { if (useGlobalLibvips()) {
buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`); buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
} else if (process.env.npm_config_build_from_source) { } else if (process.env.npm_config_build_from_source) {
buildFromSource('Detected --build-from-source flag'); buildFromSource('Detected --build-from-source flag');
}
} catch (err) {
const summary = err.message.split(/\n/).slice(0, 1);
console.log(`sharp: skipping install check: ${summary}`);
} }

2
lib/index.d.ts vendored
View File

@@ -126,7 +126,7 @@ declare namespace sharp {
function counters(): SharpCounters; function counters(): SharpCounters;
/** /**
* Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with liborc support. * Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with highway support.
* Improves the performance of resize, blur and sharpen operations by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON. * Improves the performance of resize, blur and sharpen operations by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
* @param enable enable or disable use of SIMD vector unit instructions * @param enable enable or disable use of SIMD vector unit instructions
* @returns true if usage of SIMD vector unit instructions is enabled * @returns true if usage of SIMD vector unit instructions is enabled

View File

@@ -49,11 +49,11 @@ if (sharp) {
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',
' or',
' yarn add sharp --ignore-engines', ' yarn add sharp --ignore-engines',
'- Ensure your package manager supports multi-platform installation:',
' 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} --cpu=${cpu} sharp`,
' or',
` npm install --force @img/sharp-${runtimePlatform}` ` npm install --force @img/sharp-${runtimePlatform}`
); );
} else { } else {
@@ -61,11 +61,10 @@ if (sharp) {
`- 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',
' or',
' npm install --force @img/sharp-wasm32' ' npm install --force @img/sharp-wasm32'
); );
} }
if (isLinux && /symbol not found/i.test(messages)) { if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
try { try {
const { engines } = require(`@img/sharp-libvips-${runtimePlatform}/package`); const { engines } = require(`@img/sharp-libvips-${runtimePlatform}/package`);
const libcFound = `${familySync()} ${versionSync()}`; const libcFound = `${familySync()} ${versionSync()}`;
@@ -103,7 +102,7 @@ if (sharp) {
} }
help.push( help.push(
'- Consult the installation documentation:', '- Consult the installation documentation:',
' https://sharp.pixelplumbing.com/install' ' See https://sharp.pixelplumbing.com/install'
); );
throw new Error(help.join('\n')); throw new Error(help.join('\n'));
} }

View File

@@ -183,17 +183,17 @@ function counters () {
/** /**
* Get and set use of SIMD vector unit instructions. * Get and set use of SIMD vector unit instructions.
* Requires libvips to have been compiled with liborc support. * Requires libvips to have been compiled with highway support.
* *
* Improves the performance of `resize`, `blur` and `sharpen` operations * Improves the performance of `resize`, `blur` and `sharpen` operations
* by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON. * by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
* *
* @example * @example
* const simd = sharp.simd(); * const simd = sharp.simd();
* // simd is `true` if the runtime use of liborc is currently enabled * // simd is `true` if the runtime use of highway is currently enabled
* @example * @example
* const simd = sharp.simd(false); * const simd = sharp.simd(false);
* // prevent libvips from using liborc at runtime * // prevent libvips from using highway at runtime
* *
* @param {boolean} [simd=true] * @param {boolean} [simd=true]
* @returns {boolean} * @returns {boolean}
@@ -201,7 +201,6 @@ function counters () {
function simd (simd) { function simd (simd) {
return sharp.simd(is.bool(simd) ? simd : null); return sharp.simd(is.bool(simd) ? simd : null);
} }
simd(true);
/** /**
* Block libvips operations at runtime. * Block libvips operations at runtime.

View File

@@ -1,6 +1,6 @@
{ {
"name": "@img/sharp-darwin-arm64", "name": "@img/sharp-darwin-arm64",
"version": "0.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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-s390x", "name": "@img/sharp-linux-s390x",
"version": "0.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@img/sharp-win32-ia32", "name": "@img/sharp-win32-ia32",
"version": "0.33.1-rc.0", "version": "0.33.1",
"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.33.1-rc.0", "version": "0.33.1",
"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,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.0", "version": "0.33.1",
"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,8 +141,8 @@
"semver": "^7.5.4" "semver": "^7.5.4"
}, },
"optionalDependencies": { "optionalDependencies": {
"@img/sharp-darwin-arm64": "0.33.1-rc.0", "@img/sharp-darwin-arm64": "0.33.1",
"@img/sharp-darwin-x64": "0.33.1-rc.0", "@img/sharp-darwin-x64": "0.33.1",
"@img/sharp-libvips-darwin-arm64": "1.0.0", "@img/sharp-libvips-darwin-arm64": "1.0.0",
"@img/sharp-libvips-darwin-x64": "1.0.0", "@img/sharp-libvips-darwin-x64": "1.0.0",
"@img/sharp-libvips-linux-arm": "1.0.0", "@img/sharp-libvips-linux-arm": "1.0.0",
@@ -151,15 +151,15 @@
"@img/sharp-libvips-linux-x64": "1.0.0", "@img/sharp-libvips-linux-x64": "1.0.0",
"@img/sharp-libvips-linuxmusl-arm64": "1.0.0", "@img/sharp-libvips-linuxmusl-arm64": "1.0.0",
"@img/sharp-libvips-linuxmusl-x64": "1.0.0", "@img/sharp-libvips-linuxmusl-x64": "1.0.0",
"@img/sharp-linux-arm": "0.33.1-rc.0", "@img/sharp-linux-arm": "0.33.1",
"@img/sharp-linux-arm64": "0.33.1-rc.0", "@img/sharp-linux-arm64": "0.33.1",
"@img/sharp-linux-s390x": "0.33.1-rc.0", "@img/sharp-linux-s390x": "0.33.1",
"@img/sharp-linux-x64": "0.33.1-rc.0", "@img/sharp-linux-x64": "0.33.1",
"@img/sharp-linuxmusl-arm64": "0.33.1-rc.0", "@img/sharp-linuxmusl-arm64": "0.33.1",
"@img/sharp-linuxmusl-x64": "0.33.1-rc.0", "@img/sharp-linuxmusl-x64": "0.33.1",
"@img/sharp-wasm32": "0.33.1-rc.0", "@img/sharp-wasm32": "0.33.1",
"@img/sharp-win32-ia32": "0.33.1-rc.0", "@img/sharp-win32-ia32": "0.33.1",
"@img/sharp-win32-x64": "0.33.1-rc.0" "@img/sharp-win32-x64": "0.33.1"
}, },
"devDependencies": { "devDependencies": {
"@emnapi/runtime": "^0.44.0", "@emnapi/runtime": "^0.44.0",

View File

@@ -794,11 +794,15 @@ class PipelineWorker : public Napi::AsyncWorker {
// Apply output ICC profile // Apply output ICC profile
if (!baton->withIccProfile.empty()) { if (!baton->withIccProfile.empty()) {
image = image.icc_transform(const_cast<char*>(baton->withIccProfile.data()), VImage::option() try {
->set("input_profile", processingProfile) image = image.icc_transform(const_cast<char*>(baton->withIccProfile.data()), VImage::option()
->set("embedded", TRUE) ->set("input_profile", processingProfile)
->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8) ->set("embedded", TRUE)
->set("intent", VIPS_INTENT_PERCEPTUAL)); ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
->set("intent", VIPS_INTENT_PERCEPTUAL));
} catch(...) {
sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid profile", nullptr);
}
} else if (baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) { } else if (baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) {
image = sharp::SetProfile(image, inputProfile); image = sharp::SetProfile(image, inputProfile);
} }

BIN
test/fixtures/invalid-illuminant.icc vendored Normal file

Binary file not shown.

View File

@@ -96,22 +96,28 @@ describe('libvips binaries', function () {
describe('Build time directories', () => { describe('Build time directories', () => {
it('sharp-libvips include', () => { it('sharp-libvips include', () => {
const dir = libvips.buildSharpLibvipsIncludeDir(); const dir = libvips.buildSharpLibvipsIncludeDir();
assert.strictEqual(fs.statSync(dir).isDirectory(), true); if (dir) {
assert.strictEqual(fs.statSync(dir).isDirectory(), true);
}
}); });
it('sharp-libvips cplusplus', () => { it('sharp-libvips cplusplus', () => {
const dir = libvips.buildSharpLibvipsCPlusPlusDir(); const dir = libvips.buildSharpLibvipsCPlusPlusDir();
assert.strictEqual(fs.statSync(dir).isDirectory(), true); if (dir) {
assert.strictEqual(fs.statSync(dir).isDirectory(), true);
}
}); });
it('sharp-libvips lib', () => { it('sharp-libvips lib', () => {
const dir = libvips.buildSharpLibvipsLibDir(); const dir = libvips.buildSharpLibvipsLibDir();
assert.strictEqual(fs.statSync(dir).isDirectory(), true); if (dir) {
assert.strictEqual(fs.statSync(dir).isDirectory(), true);
}
}); });
}); });
describe('Runtime detection', () => { describe('Runtime detection', () => {
it('platform', () => { it('platform', () => {
const [platform] = libvips.runtimePlatformArch().split('-'); const [platform] = libvips.runtimePlatformArch().split('-');
assert.strict(['darwin', 'linux', 'linuxmusl', 'win32'].includes(platform)); assert.strict(['darwin', 'freebsd', 'linux', 'linuxmusl', 'win32'].includes(platform));
}); });
it('arch', () => { it('arch', () => {
const [, arch] = libvips.runtimePlatformArch().split('-'); const [, arch] = libvips.runtimePlatformArch().split('-');

View File

@@ -598,6 +598,24 @@ describe('Image metadata', function () {
assert.strictEqual(undefined, metadata.icc); assert.strictEqual(undefined, metadata.icc);
}); });
it('transform to invalid ICC profile emits warning', async () => {
const img = sharp({ create })
.png()
.withIccProfile(fixtures.path('invalid-illuminant.icc'));
let warningEmitted = '';
img.on('warning', (warning) => {
warningEmitted = warning;
});
const data = await img.toBuffer();
assert.strictEqual('Invalid profile', warningEmitted);
const metadata = await sharp(data).metadata();
assert.strictEqual(3, metadata.channels);
assert.strictEqual(undefined, metadata.icc);
});
it('Apply CMYK output ICC profile', function (done) { it('Apply CMYK output ICC profile', function (done) {
const output = fixtures.path('output.icc-cmyk.jpg'); const output = fixtures.path('output.icc-cmyk.jpg');
sharp(fixtures.inputJpg) sharp(fixtures.inputJpg)

View File

@@ -9,16 +9,19 @@ const sharp = require('../../');
describe('Utilities', function () { describe('Utilities', function () {
describe('Cache', function () { describe('Cache', function () {
it('Can be disabled', function () { it('Can be disabled', function (done) {
sharp.cache(false); queueMicrotask(() => {
const cache = sharp.cache(false); sharp.cache(false);
assert.strictEqual(cache.memory.current, 0); const cache = sharp.cache(false);
assert.strictEqual(cache.memory.max, 0); assert.strictEqual(cache.memory.current, 0);
assert.strictEqual(typeof cache.memory.high, 'number'); assert.strictEqual(cache.memory.max, 0);
assert.strictEqual(cache.files.current, 0); assert.strictEqual(typeof cache.memory.high, 'number');
assert.strictEqual(cache.files.max, 0); assert.strictEqual(cache.files.current, 0);
assert.strictEqual(cache.items.current, 0); assert.strictEqual(cache.files.max, 0);
assert.strictEqual(cache.items.max, 0); assert.strictEqual(cache.items.current, 0);
assert.strictEqual(cache.items.max, 0);
done();
});
}); });
it('Can be enabled with defaults', function () { it('Can be enabled with defaults', function () {
const cache = sharp.cache(true); const cache = sharp.cache(true);