Skip to content

JPG embedded ICC profile causing problems #521

@ChrisPinewood

Description

@ChrisPinewood

I'm having trouble with the following JPG image when trying to convert it to PNG:

Problem image

It appears to be trying to use the embedded CMYK ICC profile but failing, the image itself is marked as sRGB. I did wonder if just stripping out the embedded ICC profile out would work, but I'm not sure how to do this, or whether I should be taking a different approach.

This is the code I'm using to convert (as well as resize):

  sharp(filename)
    .resize(requiredSize.width, requiredSize.height)
    .background({r: 0, g: 0, b: 0, a: 0})
    .embed()
    .png()
    .toBuffer().then((outputBuffer) => {
      resolve(outputBuffer);
    })
    .catch((err) => {
      console.log('Error creating image:', err);
      reject(err);
    });

It's very possible I'm doing something very silly in the above!

Many thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions