lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.33k stars 1.3k forks source link

Resize images while keeping the ICC profile and color space #4186

Closed ollm closed 3 months ago

ollm commented 3 months ago

Question about an existing feature

What are you trying to achieve?

I'm trying to resize images while keeping the ICC profile and color space, currently it only seems to work with the P3 profile, with other profiles it seems like sharp stretches the image (And accumulates every time it is resized). I don't know if I'm doing something wrong.

I am using sharp 0.33.4

When you searched for similar issues, what did you find that might be related?

https://github.com/lovell/sharp/issues/4008, https://github.com/lovell/sharp/issues/3906 and https://github.com/lovell/sharp/issues/4128

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

sharp('input.jpg')
    .keepIccProfile()
    .resize({kernel: 'lanczos3', width: 500})
    .png({compressionLevel: 0, force: true})
    //.toBuffer()
    .toFile('output.png');

Original

Rose-ProPhoto

Resized with keepIccProfile

Rose-ProPhoto-2

Resized with keepIccProfile 2 times

Rose-ProPhoto-3

Please provide sample image(s) that help explain this question

images.zip

lovell commented 3 months ago

Commit 2eb03b0 fixes this by preventing an unnecessary colour transformation plus adds a test that would previously have failed to help prevent regression, thanks for reporting.

ollm commented 3 months ago

Thanks you for the fix!

lovell commented 3 months ago

v0.33.5 now available with the fix.

ollm commented 3 months ago

Thanks you, I have tested the new version with different images and it works fine.