Skip to content
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

identifyFormat(%[profile:icc]) aborts execution #628

Open
banakito opened this issue Aug 13, 2023 · 4 comments
Open

identifyFormat(%[profile:icc]) aborts execution #628

banakito opened this issue Aug 13, 2023 · 4 comments

Comments

@banakito
Copy link

Hello again,

Trying to find the ICC profile name of an image:

$im = new Imagick();
$im->readImageBlob($ImageBlob);
$debug = $im->identifyFormat("%[profile:icc]");

the script aborts and the following message is logged:

stderr: "ool www: MagickCore/exception.c:1117: ThrowMagickExceptionList: Assertion `exception != (ExceptionInfo *) ((void *)0)' failed."

Thanks in advance.

@Danack
Copy link
Collaborator

Danack commented Aug 13, 2023

Ugh, to set your expectations, that looks like a bug in ImageMagick (the underlying library that does the actual work), rather than in Imagick.

Please could you send me that image or file that shows that behaviour.

As a mitigation attempt, can you do var_dump($im->count()); before the identifyFormat and check that is a sensible number, and not for example, zero.

@banakito
Copy link
Author

Hello, Danack:

$im is well populated. As far as I tested, other format strings works flawlessly:

$im->identifyFormat("%m: %wx%h"); // Returns: JPEG: 900x900
$im->identifyFormat("%[copyright]"); // Returns: (C) 1999 ImageMagick Studio LLC
$im->identifyFormat("%[resolution.x]"); // Returns:300

I've found a workaround by iterating getImageProfiles() and using a custom function to parse the result (not so clean):

// Get Profiles (ICC, EXIF, IPTC, etc.)
$Profiles = $im->getImageProfiles();
if (array_key_exists('icc', $Profiles)) {
    $IccName = MyGetIccName($Profiles['icc']); // Returns: Adobe RGB (1998)
}

I think the root cause could be ImageMagick not getting the Image Properties for icc

$Properties = $im->getImageProperties(); // Returns: values for exif, date, jpeg but no for icc

In fact, after little research, identify CLI also fails:

# identify -format "%[profile:icc]" BLO-1019.jpg
identify: unknown image property "%[profile:icc]" @ warning/property.c/InterpretImageProperties/4213.

But Imagick aborts instead raising an exception.

Thanks for your help.

@Danack
Copy link
Collaborator

Danack commented Aug 13, 2023

I think the root cause could be ImageMagick not getting the Image Properties for icc

Yeah. As you've got a reproduce case on the command line, I'd recommend opening a bug upstream at https://github.com/ImageMagick/ImageMagick or https://github.com/ImageMagick/ImageMagick6 if you're still on ImageMagick6.

I'll have look to see if I can handle the failing case better. Can you either email me or upload an example image that shows this behaviour please?

@banakito
Copy link
Author

After doing some more research, I found the main problem. It has nothing to do with the image.
I have successfully tested it on a Windows CLI and it appears to be a missing delegate in Linux.

Windows

Version: ImageMagick 7.1.1-15 Q16-HDRI x64 a0a5f3d:20230730 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP(2.0)
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib
Compiler: Visual Studio 2022 (193532217)

Linux

Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 21298 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): bzlib djvu fontconfig freetype jng jpeg lzma openexr pangocairo png tiff webp x xml zlib
Compiler: gcc (11.2)

After rebuilding ImageMagick with lcms support, the icc properties are working as expected.

So, the only thing missing would be throwing an exception when identifyFormat is invoked with a wrong property instead of aborting.

One more time, thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants