is this png background transparent?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ebolker
Posts: 2
Joined: 2018-04-21T08:55:32-07:00
Authentication code: 1152

is this png background transparent?

Post by ebolker »

I need a png known to have transparent background. I built one starting from a pdf from powerpoint with
transparent background, magicked to png, checked this way following instructions elsewhere in this forum.

$ magick identify -verbose die12t.png | grep "Alpha"
Base type: TrueColorAlpha
Alpha: 8-bit
Alpha:
Alpha: graya(0,0) #00000000
png:IHDR.color_type: 4 (GrayAlpha)

I'd like confirmation that I'm OK. If not, what else should I do?

$ magick -version
Version: ImageMagick 7.0.5-1 Q16 x64 2017-03-04 http://www.imagemagick.org
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: is this png background transparent?

Post by snibgo »

ebolker wrote:I need a png known to have transparent background.
What does that mean?

The alpha statistics will tell you if the image has transparency. For example:

Code: Select all

    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 94.4481 (0.370385)
      standard deviation: 123.141 (0.482908)
      kurtosis: -1.71183
      skewness: -0.536812
      entropy: 0.1282
The image has alpha varying from 0 (transparent) to 1 (opaque), with a mean of 0.37 (mostly transparent).
snibgo's IM pages: im.snibgo.com
ebolker
Posts: 2
Joined: 2018-04-21T08:55:32-07:00
Authentication code: 1152

Re: is this png background transparent?

Post by ebolker »

What my question means is that I did not know how to translate "Alpha = 0" to "background is transparent". Now I do. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: is this png background transparent?

Post by fmw42 »

If you just want to know if the image is fully opaque or partially transparent, then you can use

Code: Select all

convert image -format "%[opaque]" info:
See https://www.imagemagick.org/script/escape.php

If you want to know if the image is totally transparent, then use

Code: Select all

convert image -alpha extract -format "%[fx:mean]" info:
if the result is exactly 0, then the image is fully transparent. If it is exactly 1, then it is fully opaque. If in-between, then some pixels have at least partial transparency.
Post Reply