Resized Display P3 image includes Display P3 color profile but it is missing color information
See original GitHub issueI’m working on adding wide color support to my application.
I’ve got my pipeline from device -> server -> Amazon S3 working and I can successfully upload images with the Display P3 color profile from device to S3 without a loss of color information, retaining the color profile. I use libvips on my Go server as well, in order to do some initial processing.
Once the images are stored in S3, I have Sharp running in a Lambda function for Cloudfront origin requests to the S3 bucket. I have verified that a vanilla Cloudfront distribution is able to serve the wide color images correctly, but when they pass through Sharp resizing they lose color information.
I’m on the latest version, v0.29, and I’m using the attached canary image to test (it is an image that shows up in Display P3 but disappears in sRGB).
Original Canary | Broken by Sharp |
---|---|
![]() |
![]() |
If you download and inspect the images, you can see that the resulting image has the Display P3 profile but it has lost the color information.
I’m using the pipelineColorspace(“rgb16”) operator, and specifying the output icc profile. Is there something else I’m doing wrong here? Thanks!
Relevant code:
S3.getObject({ Bucket: bucket, Key: originalKey })
.promise()
.then((data) =>
Sharp(data.Body)
.pipelineColorspace("rgb16")
.resize(width, height)
.withMetadata({ icc: iccProfilePath })
.toColorspace("srgb") // I have tried with and without this line to the same result.
.toFormat(format)
.toBuffer()
)
.then((buffer) =>
S3.putObject({
Body: buffer,
Bucket: bucket,
ContentType: contentType,
Key: newKey,
}).promise()
)
.then(function () {
console.log("Redirecting to resized at: " + `/${newKey}`);
const response = {
status: "301",
statusDescription: "Moved Permanently",
headers: {
location: [
{
key: "Location",
value: `/${newKey}`,
},
],
},
};
callback(null, response);
})
.catch((err) => callback(err));
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
v0.29.1 is now available - thank you for reporting this.
Thanks, and sorry you were correct, the P3 profile is present in the GitHub image (I was looking at a previously downloaded image from a different issue with a very similar filename, d’oh).
I can reproduce the problem locally, and will need to spend a little time to debug exactly what’s happening.
In terms of the built-in “p3” profile in libvips, this is DisplayP3, which is hopefully the more useful/common flavour.