0

How - if at all - is it possible to create a fully transparent image with ImageMagick?

The problem: It's always getting a background color, white by default (as per docs)

More specifically, looking for: Not even a single background color stored in the file, so that every viewer that supports PNG will see it as a fully transparent image - just like the input

My commandline is:

magick convert in.png -trim out.png

TheGeekGuy
  • 137
  • 1
  • 7

1 Answers1

1

Standard "transparent" is a zero valued alpha channel over a black background, so rgba(0,0,0,0). If you want to ensure such, then make the background black under the transparent areas. So for example from your command assuming in.png has some transparency:

magick in.png -background black -alpha background -trim +repage out.png


Note that in ImageMagick 7, use magick, not magick convert.

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • Hm, that is already a good hint incase there's nothing better, but if I open that in Picasa Photo Viewer (for example) it shows a black background and no transparent (like it does in image editors) If I save it with [this feature](http://justpic.info/images4/29b3/2020032415_13_18ExportImageasPNG.png) in Gimp, it's displayed correctly (though the output is then also more than 3 times larger): – TheGeekGuy Mar 24 '20 at 14:20
  • When you use -trim and save to PNG, you should add +repage to remove the virtual canvas. Otherwise the image will still display with the part you trimmed off. I have added that to may command above. See the command above and try that again with the +repage added before saving to PNG – fmw42 Mar 24 '20 at 18:31