Repository navigation
Description
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- Running
npm install sharpcompletes without error. - Running
node -e "require('sharp')"completes without error.
If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
- I am using the latest version of
sharpas reported bynpm view sharp dist-tags.latest.
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.
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?
System:
OS: Linux 6.17 Arch Linux
CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
Memory: 15.66 GB / 22.84 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 24.10.0 - /home/jun/.nvm/versions/node/v24.10.0/bin/node
npm: 11.6.1 - /home/jun/.nvm/versions/node/v24.10.0/bin/npm
Does this problem relate to file caching?
The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows.
Use sharp.cache(false) to switch this feature off.
- Adding
sharp.cache(false)does not fix this problem.
Does this problem relate to images appearing to have been rotated by 90 degrees?
Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.
-
To auto-orient pixel values use the parameter-less
rotate()operation. -
To retain EXIF Orientation use
keepExif(). -
Using
rotate()orkeepExif()does not fix this problem.
What are the steps to reproduce?
- Download the provided original.jpg
- Copy the provided minimal reproducible code below into
main.mjsfile. This file should be in the same directory asoriginal.jpg. - Run
node main.mjs.
What is the expected behaviour?
The colour of the image should not change.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
import { readFileSync, writeFileSync } from "node:fs";
import sharp from "sharp";
const buf = readFileSync("original.jpg");
const s = sharp(buf);
const newBuf = await s.toBuffer();
writeFileSync("processed.jpg", newBuf);Please provide sample image(s) that help explain this problem
Original image:
Processed image:


Activity
lovell commentedon Oct 31, 2025
The sample input image provided is in the CMYK colourspace with an ICC profile. If you wish to retain this same profile and colourspace in the output, rather than the default behaviour of converting to profile-less sRGB, please see https://sharp.pixelplumbing.com/api-output/#keepiccprofile
Juneezee commentedon Oct 31, 2025
@lovell I just tried. Even with
keepIccprofile(), the colour is still different.lovell commentedon Nov 2, 2025
Ah, sorry, you'll need to explicitly add
toColourspace('cmyk')to maintain CMYK colourspace in the output image.https://sharp.pixelplumbing.com/api-colour/#tocolourspace
(I might need to update the
keepIccProfiledocs as there have been some recent upstream changes in libvips around how colourspaces and profiles are handled when saving.)Juneezee commentedon Nov 2, 2025
@lovell With
toColourspace('cmyk').keepIccProfile(), the colour is still different.I also noticed that WebStorm reports the original image as having 32-bit colour, while the processed image only has 24-bit colour.
Below are the outputs of
magick inspect --verbosefrom ImageMagick for both the original and processed images.Original image:
Processed image:
Note
I have no idea why the Colorspace field is still sRGB even when
toColourspace('cmyk')is set.Simplify ICC processing when retaining input profiles #4468
lovell commentedon Nov 4, 2025
Thanks, I've been able to reproduce locally and can see that the expected output is CMYK but the actual output is RGB. Commit e1628d8 simplifies some of the logic around this and adds the scenario from this issue as a test cases to help prevent regression.
lovell commentedon Nov 5, 2025
There's a release candidate available if you'd like to test.
Juneezee commentedon Nov 6, 2025
@lovell I install the release candidate and followed the updated comments of commit e1628d8. In my case
toColourspace("cmyk")isn't enough,pipelineColourspace("cmyk")must also be used.Thanks for fixing the issue 😊
lovell commentedon Nov 6, 2025
v0.34.5 now available
chore(deps): update dependency sharp to ^0.35.5 (#9)