-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Expose setting ICC profile via withMetadata #218
Comments
Hi Keith, the most common use case of sharp is generating images for the web so the current behaviour is to always convert images to device-independent, non-linear sRGB colour space. Using It sounds like you're hoping to use it for a different purpose, so this sounds like an excellent enhancement to make. Would an extension to |
Hi Lovell, That approach sounds ideal. Especially since it preserves your existing standard behaviour. I am working with images for print applications, where the source and destination are CMYK and chose sharp because it can handle TIFF files. I need to handle CMYK JPEG input/output too, probably not as often as TIFF. As part of the process, I am also generating RGB thumbnails and other images for use in mobile & web applications from the source TIFF and that part works perfectly, so I would love to be able to avoid having to use a different node package (or something more "low level") alongside to create the print/CMYK output. If you were up for considering adding this enhancement, that would be fantastic. :-) |
Thanks for confirming Keith. Perhaps a separate |
That sounds good too. I'm sure there are a few cases, particularly for print use where it's important that the source Colour Space is preserved in the output. I'm conscious that this is a very specific requirement that most people using sharp may not need. |
toColourspace
method (was: CMYK TIFF converted to RGB TIFF)
Note to implementer/self: The best API addition here is probably This should change the output colourspace and, when For multi-English consistency, |
Note to implementer/self: Ensure any new ICC profiles added as part of this (e.g. P3) are suitable for packaging with Debian - see #486 |
v0.16.0 adds the toColourspace operation that provides some of what's needed here. The next step would be to accept ICC profiles (via |
As promised, my thoughts on how the 1: sharp(rgbInput)
.withMetadata()
... should inject the default sRGB profile. 2: sharp(rgbInput)
.toColorspace('cmyk')
.withMetadata()
... should inject the default CMYK profile. 3: sharp(rgbInput)
.withMetadata({
profile: '/path/to/alternative-rgb-profile.icc'
})
... should inject the specified RGB profile (no colourspace conversion). 4: sharp(rgbInput)
.toColorspace('cmyk')
.withMetadata({
profile: '/path/to/alternative-cmyk-profile.icc'
})
... should inject the specified CMYK profile. 5: The existing behaviour of removing any profile when |
This sounds very doable. How much error detection / sanity checing should |
@mhirsch Thank you. Sadly I suspect there's very little we can do given all this API will be doing is attaching otherwise random bytes to the output image's metadata. I've seen all manner of invalid colour space and profile combinations and will remain happy as long as |
@lovell I'm taking a look at this again after a long break. What motivated me to open #550 was the exact error noted in #584. My intention with What if we were to modify the proposed Does this sound acceptable? |
@mhirsch How about exposing control over the input profile through the existing input options, something like: sharp(input, { profile: '/path/to/profile.icc' })... We should be able to use libvips' icc_transform operation for this. When a custom profile is specified, set |
Is the above change in the
which uses the embedded profile.
Specifying a string path would use that particular profile in output instead of the embedded profile |
Just to chime in with a use case for The iPhone 7 now by default generates JPEGs with the Sharp will currently embed a default Would love the option to specify the profile using I'm still investigating if the output images are still In a perfect world it would be great to have the |
If there's an embedded P3 profile in the input, sharp/libvips currently uses this to convert pixels to non-linear sRGB value via lcms2. This means output colours will be as close as possible, but conversion from P3 to sRGB will reduce the gamut, especially in the orange region. |
Thanks for chiming in @lovell , this is what I sussed out in my tests last night. So if a Been using the new devices and the difference of a sunset photo in a P3 image vs one that has been downgraded to sRGB is surprisingly dramatic when compared side by side. 🌇 😍 |
@caesar The current conversion to sRGB would no longer be forced as a result of this work, although it would still remain the default behaviour unless told otherwise. |
@lovell that's fantastic news! It's not clear to me from the above – is this currently being implemented, or still in the API proposals stage? Is it going to be a big job / take a long time to implement? I would happily offer to help with the implementation, but I am not familiar with libvips and not that knowledgable on image processing in general, so I fear I don't have much to offer... |
How's the progress on non-sRGB processing? Any tasks we could help with, any testing needed to be done? |
Hi What is the progress on this API implementation? I was having a problem with the CMYK image. Some clarity would help. If I have a CMYK image that is initially without a profile and I attach a profile like this one |
@RNanwani If there's an embedded profile on the input image, sharp will currently always attempt to use it to convert to the device-independent sRGB colour space. Whilst there is a |
Then I convert jpg image from srgb to cmyk, get an error:
Is this corrent code, or I need somthing else? sharp('path/to/file_input.jpg')
.toColorspace('cmyk')
.withMetadata({
profile: 'path/to/profile.icc'
})
.toFile('path/to/file_output.jpg'); |
@shot131 This is, so far, a discussion about what future possible modifications to the |
It would be really great to get this issue solved so that Sharp can be used with CMYK (and other non-sRGB) images. Is there anything we can do to help? |
Chiming in with my use case: ideally I would like to retain the embedded profile of the input image (no conversion), and strip all other metadata. I'm generating thumbnails for photos that photographers are uploading, and the color should be accurate, but none of the other metadata matters. I'm using imagemagick currently and this seems to be the only feature that sharp can't match. |
toColourspace
method (was: CMYK TIFF converted to RGB TIFF)
Coming with my use case: I have some images (not sRGB) without ICC profile, I have a ICC profile that I would like to use to convert them to sRGB, As far as I got this is not yet possible with sharp, right? |
Thanks everyone for all the comments and suggestions on this issue; please keep them coming. It's clear there are many use cases required around colour profiles that sharp does not currently support so I will split this issue into a few different tasks e.g. custom input profiles, custom output profiles, custom profiles for colourspace conversion. |
Will this require any changes in libvips? |
So, I am confused. Is it possible to start with a source file that is CMYK, perform operations on it, and then save it back out as a CMYK? source1.tif (CMYK) When I attempt to use toColorspace('cmyk'), I get the error "vips_colourspace: no known route from 'srgb' to 'cmyk'". It appears this is not possible, but I need to know for sure so I can decide how / if to use this library. I appreciate any guidance on this. Thanks! |
No, it's not possible.
|
Thanks Caeser. I guess one approach is to do the work with Sharp, but then use a different approach to convert as a post-processing step. Do you know if the issue is with Sharp or with libvips? |
@lovell can we split this issue to track them better? If needed I would love to offer my axe to resolve the issue especially around the output CMYK part. |
I've split this discussion into 3 new issues. Please feel free to +1, subscribe to and comment on as many as you're interested in.
Thank you all for the comments and suggestions so far. |
When I resize a CMYK TIFF, and output to TIFF the output file is RGB not CMYK.
Do I need to configure the output somehow to enable CMYK output?
Here is the code I am using:
The text was updated successfully, but these errors were encountered: