Re: convert CMYK image to SRGB
Bob Friesenhahn <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 31 Jul 2015, James Bardin wrote: > I know that `gm convert -colorspace RGB` will convert the image for me (though it doesn't take into account the > color profile), but I'm completely missing something trying to do that from the C api. > > Instead of going over what hasn't worked, could someone start me off in the right direction? QuantizeImage seems > to be the only thing I can find related, but I haven't got any usable results. > > Depending on how the transformation works, I'd like to be able to take into account the embedded iptc cmyk > profile and be able normalize the image to srgb IEC61966-2.1, but I haven't been able to get anything but > photoshop to do this correctly. The core function which does the work is ProfileImage(). If this function is used when the image has no attached profile, then the new profile is simply attached to the image (similar to SetImageProfile()). If this function is used when the image already has an attached profile, then a CMS transform is performed using the two profiles. The ProfileImage() function expects that the profile is provided in memory rather than a file. The utility function FileToBlob() can be used to read a file into a memory buffer although for this purpose ReadImage() is used by the command-line code to read the profile since then it can be read by the ICC/ICM reader, or retrieved from a JPEG file or other formats supporting an attached ICM profile. You definitely want to avoid using -colorspace to convert CMYK to RGB since it uses a crude algorithm which does not handle color profiles. QuantizeImage() is for color reduction, not colorspace translation. The documentation for ProfileImage() may be found at http://www.graphicsmagick.org/api/profile.html#profileimage Bob -- Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ ------------------------------------------------------------------------------ _______________________________________________ Graphicsmagick-help mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help