Open banakito opened 1 year ago
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.
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.
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?
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.
Hello again,
Trying to find the ICC profile name of an image:
the script aborts and the following message is logged:
Thanks in advance.