convert crashes when applying colour profile to some images

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.
Post Reply
cmdrwalrus
Posts: 3
Joined: 2019-12-10T17:46:33-07:00
Authentication code: 1152

convert crashes when applying colour profile to some images

Post by cmdrwalrus »

We have a script that crops and resizes JPEGs, and it also optimizes them, which includes applying an RGB colour profile. For most images, this works just fine. But we have a dozen or so images that cause convert to crash when applying the profile.

The profile is sRGB_v4_ICC_preference.icc from color.org. One of the troublesome images is here:
https://www.lodgingcompany.com/photos/2 ... 4zqdI.jpeg

This happens on Debian 10 (buster) with ImageMagick 6.9.10-23 Q16 x86_64 20190101.

The conversion works OK (with a warning) on Debian 8 (jessie) with ImageMagick 6.8.9-9 Q16 x86_64 2019-10-21.
This is the warning:
convert: color profile operates on another colorspace `icc' @ error/profile.c/ProfileImage/1064.

It appears these images have broken colour profiles. But regardless, if it's possible to continue working after a warning, that would be preferred!

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

Re: convert crashes when applying colour profile to some images

Post by snibgo »

"identify" shows your jpeg is encoded with RGB channels but with an embedded CMYK profile. Any attempt to convert it to another colorspace is doomed. I suggest "-strip" to remove the incompatible profile, or "-set profile {your sRGB profile}.icc".
snibgo's IM pages: im.snibgo.com

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

Re: convert crashes when applying colour profile to some images

Post by dlemstra »

What happens when you update ImageMagick to the latest version?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

cmdrwalrus
Posts: 3
Joined: 2019-12-10T17:46:33-07:00
Authentication code: 1152

Re: convert crashes when applying colour profile to some images

Post by cmdrwalrus »

snibgo wrote:
2019-12-10T18:52:48-07:00
"identify" shows your jpeg is encoded with RGB channels but with an embedded CMYK profile.
Yeah, that's what I discovered. So the best approach now will be detecting that case so we can skip the profile set and just call strip. The trick will be how to detect in my perl script whether the colorspace matches the profile. I'm sure I can figure it out, but do you have any clues?

Thanks!

cmdrwalrus
Posts: 3
Joined: 2019-12-10T17:46:33-07:00
Authentication code: 1152

Re: convert crashes when applying colour profile to some images

Post by cmdrwalrus »

Here's another thread with the same issue, and a few helpful tips:

https://imagemagick.org/discourse-serve ... hp?t=35746

Post Reply