Open richhost opened 4 months ago
My operating system is macOS, and I use a display with P3 color.
The input image contains a P3 ICC profile.
https://sharp.pixelplumbing.com/api-output#keepiccprofile
sharp('img.png')
.resize({ width: 800 })
.keepIccProfile()
.toFile("out.png");
I tried the above code, but it didn't work.
I took a closer look and the compressed iCCP
chunk in the sample PNG image you've provided, which is where the PNG format stores ICC profiles, cannot be decompressed via libspng. This means that libspng reports that there is no profile. Here's the output from metadata()
for this image - note hasProfile: false
.
{
format: 'png',
width: 738,
height: 1758,
space: 'srgb',
channels: 4,
depth: 'uchar',
density: 216,
isProgressive: false,
hasProfile: false,
hasAlpha: true
}
When using libvips compiled with support for libpng there is an ICC profile available, so my best guess would be that this relates to https://github.com/randy408/libspng/issues/14. Do you know the source of this image? Perhaps the compressed zlib stream within the iCCP
chunk is truncated?
Please can you report this issue upstream at https://github.com/randy408/libspng
The DEFLATE stream within the iCCP
chunk appears to be truncated for this particular image, according to both exiftool and https://www.nayuki.io/page/png-file-chunk-inspector.
$ exiftool -icc_profile -b x.png
Warning: Error inflating iCCP - x.png
@kleisauke Thanks for confirming my suspicions, I'm not sure how libpng manages to inflate the truncated profile though :shrug:
@lovell Thank you for the information. I exported a PNG image with the P3 Color profile using Figma. In Sharp, it shows hasProfile: false
.
@richhost Thank you, in that case please can you report this to Figma.
@richhost Were you able to report this to Figma? If so, what did they say?
@richhost Were you able to report this to Figma? If so, what did they say?
@lovell Yes, I sent an email to Figma two weeks ago, but I haven't heard back yet.
@richhost Have you had any response from Figma?
@jake-figma Wearing your Figma Developer Advocate hat, are you able to provide any insight into this? The summary is that it appears Figma is currently exporting PNG images with corrupt P3 ICC profiles. Thank you.
@lovell Unfortunately, I have not received any response from Figma, and the problem still persists. If @jake-figma sees this message, I would greatly appreciate if he could help follow up on this issue.
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.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?
sharp
as reported bynpm 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
?Does this problem relate to file caching?
The default behaviour of libvips is to cache input files, which can lead to
EBUSY
orEPERM
errors on Windows. Usesharp.cache(false)
to switch this feature off.sharp.cache(false)
does not fix this problem.Does this problem relate to images appearing to have been rotated by 90 degrees?
Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.
To auto-orient pixel values use the parameter-less
rotate()
operation.To retain EXIF Orientation use
keepExif()
.[ ] Using
rotate()
orkeepExif()
does not fix this problem.What are the steps to reproduce?
My operating system is macOS, and I use a display with P3 color.
What is the expected behaviour?
Keep the original colors.
Please provide sample image(s) that help explain this problem
original image:
output image: