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
using -define png:color-type=2 add grey row to bottom
using -define png:color-type=2 add grey row to bottom
James Maeding
Civil Engineer / Programmer
Civil Engineer / Programmer
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: using -define png:color-type=2 add grey row to bottom
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: using -define png:color-type=2 add grey row to bottom
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
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
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.
I tried the code above, and it does replace the color with trans, but the final png is Indexed Color.
James Maeding
Civil Engineer / Programmer
Civil Engineer / Programmer
Re: using -define png:color-type=2 add grey row to bottom
wait, it did work. I ran an old script on accident.
Dang, Fred gets it in one! very nice.
Dang, Fred gets it in one! very nice.
James Maeding
Civil Engineer / Programmer
Civil Engineer / Programmer
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: using -define png:color-type=2 add grey row to bottom
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: using -define png:color-type=2 add grey row to bottom
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.