Page 1 of 1

using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T15:27:49-07:00
by jmaeding
I have a bunch of 16x16 pixel button images, whose "background" color was 192,192,192.
I need to replace that with transparency, and save as RGB png.
The replace is easy using:
(step1)
magick mogrify -fuzz 0%% -transparent "rgb(192,192,192)" "C:\CAD_Support\Menu Images\*.png"
But then many images get saved with indexed palette, not 24 bit rgb.
So I convert to RGB with:
(step 2)
magick mogrify -define png:color-type=2 "C:\CAD_Support\Menu Images\*.png"

and it runs, but on many images I get a grey (194,194,194) row along the bottom.
I can't get rid of that row, as step 1 converts it back to indexed palette.

I tried many other things, but none helped, only did bad things like removing transparency.
Am I dealing with a canvas edge issue?
thanks

Re: using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T15:58:09-07:00
by fmw42
What is your ImageMagick version 7.x.x.x and platform (presumed Windows)? Please always provide that information. Can you post one example input image

Re: using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T16:03:10-07:00
by fmw42
I think if you want to keep transparency you need to use color-type=6. See https://www.imagemagick.org/Usage/formats/#png_write

Try

Code: Select all

magick mogrify -define png:color-type=6 -fuzz 0%% -transparent "rgb(192,192,192)" *.png

Re: using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T16:19:58-07:00
by jmaeding
sorry, on windows 10, IM version 7.0.5-Q8
I tried the code above, and it does replace the color with trans, but the final png is Indexed Color.

Re: using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T16:23:02-07:00
by jmaeding
wait, it did work. I ran an old script on accident.
Dang, Fred gets it in one! very nice.

Re: using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T16:38:21-07:00
by fmw42
Yes, it should have worked. I tested it on the logo: image making white transparent and the result was 32-bit color. Glad if worked for you.

Re: using -define png:color-type=2 add grey row to bottom

Posted: 2018-07-30T16:40:45-07:00
by fmw42
jmaeding wrote: 2018-07-30T16:19:58-07:00 sorry, on windows 10, IM version 7.0.5-Q8
I tried the code above, and it does replace the color with trans, but the final png is Indexed Color.
An easy way not to forget, especially for users who do not upgrade often, is to put the version and platform information in your footer. But then you have to be sure to update it when you upgrade.

You might consider an upgrade now. I am not sure what 7.0.5.x you are using, but we are now at 7.0.8.8. So as much as 30 or more versions old.