Replacing color in png is not working in latest imagemagick versions

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
anoopvt
Posts: 3
Joined: 2018-12-03T22:06:34-07:00
Authentication code: 1152

Replacing color in png is not working in latest imagemagick versions

Post by anoopvt »

Hi i have th following imagemagick command in my application, it used for applying various colors to cliparts,the problem is it not working as expected in the latest imagemagick versions such as Version: ImageMagick 7.0.7-23 Q16 x86_64 2018-02-19,this is the output i am getting for below commannd

convert test1.png -colorspace Gray -fill black -tint 100 -modulate 110,100,100 test2.png
convert test2.png +level-colors '#00aeef', test2.png

Image to Image

but in Imagemagick Version: ImageMagick 6.8.8-10 Q16 x86_64 2015-10-19 i get perfect output like this for the same command
Image

please help me guys i am really stuck here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replacing color in png is not working in latest imagemagick versions

Post by fmw42 »

I can confirm the same issue in IM 7.0.8.15 Q16 Mac OSX Sierra.

However, note that with IM 7 you should be using magick not convert. Also your second command has an extra comma that should not be there. Also your code produces a blue color, not a green one. So perhaps you changed the hex color.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replacing color in png is not working in latest imagemagick versions

Post by snibgo »

For v7, operations apply to the alpha channel by default. To prevent this, use "-channel RGB" before the operation and "+channel" after.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replacing color in png is not working in latest imagemagick versions

Post by fmw42 »

snibgo wrote: 2018-12-04T10:00:22-07:00 For v7, operations apply to the alpha channel by default. To prevent this, use "-channel RGB" before the operation and "+channel" after.
Ah! I keep forgetting this.

This works for me in IM 7.0.8.15

magick test1.png -colorspace Gray -fill black -tint 100 -modulate 110,100,100 test2.png
magick test2.png -channel rgb +level-colors '#00aeef' test2.png
anoopvt
Posts: 3
Joined: 2018-12-03T22:06:34-07:00
Authentication code: 1152

Re: Replacing color in png is not working in latest imagemagick versions

Post by anoopvt »

using "-channel rgb " did the trick for me,now it is working,thanks fmw42
Last edited by anoopvt on 2018-12-04T23:35:39-07:00, edited 1 time in total.
anoopvt
Posts: 3
Joined: 2018-12-03T22:06:34-07:00
Authentication code: 1152

Re: Replacing color in png is not working in latest imagemagick versions

Post by anoopvt »

convert test1.png -colorspace Gray -fill black -tint 100 -modulate 110,100,100 test2.png
convert test2.png -channel rgb +level-colors '#00aeef' test2.png

i am still using convert command and it is working in both 6.8 and 7 imagemagick version,why should i use magick command instead of convert, i am asking this because i have tons of other convert commands in my application,is there any deprecation of commands going on.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replacing color in png is not working in latest imagemagick versions

Post by fmw42 »

In ImageMagick 7, convert will use IM 6 rather than IM 7 commands, unless you have a symbolic link between the two.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replacing color in png is not working in latest imagemagick versions

Post by snibgo »

anoopvt wrote:... is there any deprecation of commands going on.
Yes. V6 syntax is more loosely defined than v7 syntax, and is deprecated. A v6 syntax command can be ambiguous, so difficult to predict what IM will do and in what order. V7 syntax is stricter and more predictable.

[EDIT: corrected "V7" to "V6". ]
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replacing color in png is not working in latest imagemagick versions

Post by fmw42 »

Post Reply