Page 1 of 1

Replacing color in png is not working in latest imagemagick versions

Posted: 2018-12-04T02:51:33-07:00
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.

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

Posted: 2018-12-04T09:45:01-07:00
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.

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

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

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

Posted: 2018-12-04T10:12:46-07:00
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

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

Posted: 2018-12-04T23:27:43-07:00
by anoopvt
using "-channel rgb " did the trick for me,now it is working,thanks fmw42

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

Posted: 2018-12-04T23:33:32-07:00
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.

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

Posted: 2018-12-05T00:11:45-07:00
by fmw42
In ImageMagick 7, convert will use IM 6 rather than IM 7 commands, unless you have a symbolic link between the two.

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

Posted: 2018-12-05T07:47:06-07:00
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". ]

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

Posted: 2018-12-05T11:11:25-07:00
by fmw42