Error on converting to i1Profiler ICM Profile

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Locked
VasyaIvonov2
Posts: 21
Joined: 2019-10-29T07:03:33-07:00
Authentication code: 1152

Error on converting to i1Profiler ICM Profile

Post by VasyaIvonov2 »

Hi.

If I'm trying to convert any image to ICMProfile, created by i1Profiler (from X-Rite), I'm seeing the next:
magick.exe convert -profile sRGB.icc "Test.jpg" -profile "Scanner_29-10-19_v2.icm" "\processed.jpg"
convert: unable to transform colorspace `\Test.jpg' @ warning/profile.c/CMSExceptionHandler/491.
convert: unable to create color transform `icc' @ error/profile.c/ProfileImage/1140.
I opened ImageMagick SourceCode on profile.c:
https://github.com/ImageMagick/ImageMag ... /profile.c
and looked at line 1140:
transform=AcquireTransformThreadSet(source_profile,source_type,
target_profile,target_type,intent,flags,&cms_exception);
if (transform == (cmsHTRANSFORM *) NULL)
ThrowProfileException(ImageError,"UnableToCreateColorTransform",
name);
Obviously, this error is thrown when AcquireTransformThreadSet function returns NULL.
But what it means? Is ICM Profile corrupted? I open it with ICC Profile Inspector and It opens normally.
Where can I get more verbose information? I need to apply ICM Profiles from i1Profiler to images...

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error on converting to i1Profiler ICM Profile

Post by snibgo »

What version of IM, on what platform?

Your command is bad. Your first "-profile" operation has no input image, so it does nothing. Your second "-profile" will do something. If "Test.jpg" has no profile, then it will assign the icm profile.

I suggest you use "magic", not "magick convert".

Please link to your inputs Test.jpg and Scanner_29-10-19_v2.icm.
snibgo's IM pages: im.snibgo.com

VasyaIvonov2
Posts: 21
Joined: 2019-10-29T07:03:33-07:00
Authentication code: 1152

Re: Error on converting to i1Profiler ICM Profile

Post by VasyaIvonov2 »

So:
1. IM version: (magick.exe -version)
Version: ImageMagick 7.0.9-1 Q16 x64 2019-10-28 http://www.imagemagick.org
2. Platform Windows 10 64-bit.
3. You said: "
"Your first "-profile" operation has no input image, so it does nothing"
But if I use next command with working ICC Profile (grayscale.icm - https://ufile.io/qracoigp):
magick.exe convert "Test.jpg" -verbose -profile "grayscale.icc" "processed.jpg"
Processed.jpg is not grayscale at all.
4. My Test.jpg has no embedded profile. Link: https://ibb.co/d5dw7L6.
5.
"then it will assign the icm profile".

Is there any difference between "apply icm profile" and "assign icm profile"? I need to change image colors, not simply embed profile to image.
6.
I suggest you use "magic", not "magick convert".
What difference? I installed ImageMagick (ImageMagick-7.0.9-1-Q16-HDRI-x64-dll.exe) and in folder ImageMagick-7.0.9-Q16-HDRI has no convert.exe app, only magick.exe.
7. ICM Profile Scanner_29-10-19_v2: https://ufile.io/wborek3l
It created with i1Profiler with ICC Profile version: Version 2.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error on converting to i1Profiler ICM Profile

Post by snibgo »

Your questions, not in the same order:

6. "magick convert" will use the IM v6 syntax. This won't object to an operation "-profile XXX" before there is an image, but it does nothing because there is no image. "magick" alone will use the v7 syntax which is stricter, and it will tell you that "-profile" when there is no image is bad syntax:

Code: Select all

magick -profile sRGB.icc Test.jpg out.jpg

magick: no images found for operation `-profile' at CLI arg 1 @ error/operation.c/CLIOption/5295.
5. Assigning a profile merely sets metadata, embedding the new profile. It doesn't change pixel values, or the meaning of the channels (the "colour model", eg RGB or CMYK). Converting from one profile to another profile sets metadata but also re-calculates every pixel, and may change the meaning of channels, and may increase or reduce the number of channels, eg when changing from sRGB to CMYK.

"Applying" a profile is ambiguous. It doesn't really mean anything.

4. Your Test.jpg has no profile. The colour model is RGB. If we want to change its profile, we must first assign an appropriate profile (eg sRGB), then convert to whatever profile we want:

Code: Select all

magick Test.jpg -profile sRGB.icc -profile grayscale.icc processed.jpg
snibgo's IM pages: im.snibgo.com

VasyaIvonov2
Posts: 21
Joined: 2019-10-29T07:03:33-07:00
Authentication code: 1152

Re: Error on converting to i1Profiler ICM Profile

Post by VasyaIvonov2 »

Thanks for answer.
But my question is not solver yet, because
magick.exe "Test.jpg" -verbose -profile sRGB.icc -profile "Scanner_29-10-19_v2.icm" "processed.jpg"
Outputs error:
magick.exe: unable to transform colorspace `Test.jpg' @ warning/profile.c/CMSExceptionHandler/491.
magick.exe: unable to create color transform `icc' @ error/profile.c/ProfileImage/1140.
What's wrong with this ICM Profile?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error on converting to i1Profiler ICM Profile

Post by snibgo »

Sorry, I don't know much about profiles. For scanner_29-10-19_v2.icm, wxProfileDump reports validation warnings:

Code: Select all

Warning! -  - Unknown: Unregisterd CMM signature.
Warning! - AToB0Tag - Matrix must be identity.
Warning! - AToB1Tag - Matrix must be identity.
Warning! - AToB2Tag - Matrix must be identity.
I also notice that the red, green and blue colorant tags are all X=Y=Z=1. This seems very strange to me, but perhaps it is okay.

EDIT: Yes, the colorants are the problem. When I change them to sRGB colorants, IM converts to that profile with no complaint. Of course, those colorants are probably wrong for your scanner.
snibgo's IM pages: im.snibgo.com

VasyaIvonov2
Posts: 21
Joined: 2019-10-29T07:03:33-07:00
Authentication code: 1152

Re: Error on converting to i1Profiler ICM Profile

Post by VasyaIvonov2 »

Thank you for the answer. How to change those 'colorants'? What is right values?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error on converting to i1Profiler ICM Profile

Post by snibgo »

I changed the colorants with "ICC Profile Inspector", http://www.color.org/profileinspector.xalter .

Where did scanner_29-10-19_v2.icm come from? Did you create it? I don't know what the colorants should be. They will depend on the hardware.

I don't know what that profile is for. Perhaps it is an input profile for a scanner. If so, then the proper use would be to assign the scanner_29-10-19_v2.icm profile to a scanned image, then convert to a sRGB profile, or whatever you want.
snibgo's IM pages: im.snibgo.com

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error on converting to i1Profiler ICM Profile

Post by dlemstra »

Can you share your test.jpg so I can test if we could improve this warning message?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error on converting to i1Profiler ICM Profile

Post by snibgo »

Test.jpg is linked upthread: https://ibb.co/d5dw7L6
snibgo's IM pages: im.snibgo.com

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error on converting to i1Profiler ICM Profile

Post by dlemstra »

Thanks Snibgo I missed that. Just pushed a patch to include the message from the lcms library in the exception. Doesn't really give me more information though:

Code: Select all

magick.exe: UnableToTransformColorspace `I:\issues\im\board36988\Test.jpg', Couldn't link the profiles (#13) @ warning/profile.c/CMSExceptionHandler/490.
magick.exe: unable to create color transform `icc' @ error/profile.c/ProfileImage/1151.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Locked