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

stats() on CMYK image: vips_colourspace: no known route from 'cmyk' to 'b-w' #1619

Closed
rexxars opened this issue Mar 22, 2019 · 6 comments
Closed

Comments

@rexxars
Copy link
Contributor

rexxars commented Mar 22, 2019

The following code (with a CMYK JPEG as input) gives the error outlined below:

const sharp = require('sharp')
sharp('cmyk.jpg')
  .stats()
  .then(res => console.log('SUCCESS', res))
  .catch(err => console.error('ERROR', err))

Output:

ERROR [Error: vips_colourspace: no known route from 'cmyk' to 'b-w']

The following seems to work:

const sharp = require('sharp')
sharp('cmyk.jpg')
  .toColorspace('srgb')
  .toBuffer()
  .then(res => sharp(res).stats())
  .then(res => console.log('SUCCESS', res))
  .catch(err => console.error('ERROR', err))
@lovell
Copy link
Owner

lovell commented Mar 22, 2019

Hi, is this a CMYK JPEG that is missing a profile? There's no logic in sharp's stats pipeline to deal with this. (sharp does have custom logic for this in the usual processing pipeline, which is why that works.)

We could add logic to stats to deal with this but the forthcoming libvips v8.8.0 will add its own internal fallback CMYK profile anyway so it's probably best to just wait and we can instead remove all the logic around this from sharp.

@rexxars
Copy link
Contributor Author

rexxars commented Mar 22, 2019

I wouldn't know - I'm told it's just a standard jpeg exported from photoshop. No big deal for me since I can just convert it to a different colorspace when this happens, just figured it might be a bug since you could resize it without issues. Anyway- feel free to close if you feel like this is covered by the new libvips 👍

@lovell
Copy link
Owner

lovell commented Mar 22, 2019

Let's leave this open as I'd like to add a test for this scenario after the next libvips upgrade. Thanks for reporting.

@lovell
Copy link
Owner

lovell commented Jul 29, 2019

Commit 417cca6 adds this as a test, which now passes, and switches to use libvips' new built-in profiles. This will be in v0.23.0.

@lovell
Copy link
Owner

lovell commented Jul 29, 2019

sharp v0.23.0 / libvips v8.8.1 is now available.

@lovell lovell closed this as completed Jul 29, 2019
@sebastienbarre
Copy link

Hi. Sorry to chime-in that late, but I can't get this to work either:

  sharp(file)
    .toColorspace('lch')
    .toBuffer()
    .then(data => sharp(data).stats())
    .then(stats => console.log(stats))
    .catch(error => signale.error('Failed getting stats. ' + error.message));

This returns the same stats, whether I convert to 'srgb', or 'lch', or 'lab'. Am I not understanding the stats function correctly? I thought it would give me the stats for the L, C, H channels, which would be different than stats for R, G, B channels.

Thanks

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

3 participants