Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withMetadata() behaves differently than withMetadata({icc: 'srgb'}) #3761

Closed
3 tasks done
mertalev opened this issue Aug 14, 2023 · 1 comment
Closed
3 tasks done

Comments

@mertalev
Copy link
Contributor

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes 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 sharp as reported by npm 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 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (16) x64 AMD Ryzen 7 5800X3D 8-Core Processor
    Memory: 7.55 GB / 15.62 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 18.17.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - /usr/local/bin/npm

What are the steps to reproduce?

  1. Convert an image using withMetadata without any args
  2. Convert an image using `withMetadata({icc: 'srgb'})
  3. Note that the colors and file sizes are different (passing {icc: 'srgb'} produces better colors)
  4. Also note that inspecting them with exiftool shows different data

What is the expected behaviour?

The default behavior explained in the documentation suggests that these should be equivalent, with options.icc defaulting to 'srgb'.

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

const sharp = require('sharp');

await sharp('dog.png')
  .withMetadata()
  .toFile('dog-srgb-noargs.jpeg');

await sharp('dog.png')
  .withMetadata({icc: 'srgb'})
  .toFile('dog-srgb-icc.jpeg');

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

Original:

dog-small

withMetadata():

dog-small-noicc-srgb

withMetadata({icc: 'srgb'}):

dog-small-icc-srgb

@lovell
Copy link
Owner

lovell commented Aug 15, 2023

Thanks for reporting, not sure exactly when this regressed (the docs are correct), I've fixed this and added a test via commit bb7469b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants