no ICC profile conversion perfrmd - Magick::Image::profile()

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
whatdoido
Posts: 27
Joined: 2011-01-22T16:54:46-07:00
Authentication code: 8675308

no ICC profile conversion perfrmd - Magick::Image::profile()

Post by whatdoido »

Hi,

I am using the C++ API - I have a aRGB jpg loaded into memory and construct a Image object and wish to perform a ICC color profile conversion.

Code: Select all

        Magick::Image  magick(argv[1]);

        uchar_t*  profile = NULL;
        size_t  profile_length = 0;

        // alloc buf space for profile and read target ICC profile from disk
        ...

        magick.profile("ICM", Magick::Blob(profile, profile_length) );
        magick.quality(100);
        magick.write("converted.jpg");
However, when I view the converted.jpg image, there is no conversion. It looks exactly the same as the original aRGB image. Using exiftool, I also see no reference to the expected target (sRGB) profile.

When I use the convert util

Code: Select all

convert -profile NKAdobe.icm aRGB.jpg -profile NKsRGB.icm sRGB.jpg
the converted image (sRGB.jpg in this case) has clearly had the conversion applied.

I can see that Magick::Image::profile() simply calls ProfileImage(), whose comments in profile.c state that
ProfileImage() associates, applies, or removes an ICM, IPTC, or generic profile with / to / from an image. If the profile is NULL, it is removed
Am I mis-using the API? Additionally, how would I specify which rendering intent (for example, perceptual) to use during the conversion?

thanks in advance
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: no ICC profile conversion perfrmd - Magick::Image::profi

Post by magick »

Profile transformations requires two color profiles, a source and destination. If you apply one color profile. its associated with the image but no color transformation is applied.
whatdoido
Posts: 27
Joined: 2011-01-22T16:54:46-07:00
Authentication code: 8675308

Re: no ICC profile conversion perfrmd - Magick::Image::profi

Post by whatdoido »

Thanks. So to clarify, I would need to call Image::profile(..) twice: one to set the ICC profile of the image pre-conversion and then again with the target ICC profile and at this point the conversion will be applied?

How would one specify the rendering intent?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: no ICC profile conversion perfrmd - Magick::Image::profi

Post by magick »

Correct. Use renderingIntent() to specify the rendering intent. Choose from SaturationIntent, PerceptualIntent, AbsoluteIntent, and RelativeIntent.
whatdoido
Posts: 27
Joined: 2011-01-22T16:54:46-07:00
Authentication code: 8675308

Re: no ICC profile conversion perfrmd - Magick::Image::profi

Post by whatdoido »

Thanks. I am still having trouble with this. I have a very simple test program

Code: Select all

	Magick::Image  magick("adobe.jpg");

	magick.renderingIntent(Magick::PerceptualIntent);

	magick.profile("ICM", Magick::Blob(aRGB, aRGBsz));

	const Magick::Blob  targetICC(sRGB, sRGBsz);
	magick.profile("ICM", targetICC);
	magick.iccColorProfile(targetICC);

	magick.write("srgb.jpg");
This is what was discussed. It opens a file that is in Adobe RGB and does the conversion.

However, when compared against the output from the 'convert' util, the image from the sample program is noticably different. The program's output looks exactly like the original. I am a little lost. Any thoughts?

thanks in advance.


The following files are available - these are the files I've been using to demonstrate my problem:

sample program; https://sites.google.com/site/devdump12 ... ects=0&d=1

original aRGB image: https://sites.google.com/site/devdump12 ... edirects=0
sample program ICC converted image: https://sites.google.com/site/devdump12 ... edirects=0

convert utli output: https://sites.google.com/site/devdump12 ... edirects=0

input (Nikon) aRGB profile: https://sites.google.com/site/devdump12 ... ects=0&d=1
output (Nikon) sRGB profile: https://sites.google.com/site/devdump12 ... ects=0&d=1
whatdoido
Posts: 27
Joined: 2011-01-22T16:54:46-07:00
Authentication code: 8675308

Re: no ICC profile conversion perfrmd - Magick::Image::profi

Post by whatdoido »

Actually, forget that. I've just replaced references to "ICM" to "ICC" and that's worked!!

What are the differences between ICM and ICC when specifying this to the Image::profile(..) method?
Post Reply