-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Resized Display P3 image includes Display P3 color profile but it is missing color information #2862
Description
I'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));

