Page 1 of 1
Problem extracting alpha channel from indexed palette PNGs
Posted: 2011-09-08T17:01:48-07:00
by vtagle-qsi
Hello,
I have a PNG file with an indexed palette and I'm trying to extract the alpha channel to use as an image mask but all the usual techniques I've tried have failed. Is there some trick to doing it? The best I can figure is I have to convert it to RGB but I can't seem to do that without losing the alpha channel completely.
Edit: Updated the subject to be more clear.
Re: Problem extracting alpha channel from indexed palette PN
Posted: 2011-09-08T17:39:50-07:00
by fmw42
What version of IM are you using? PNG has undergone much developement over the last few months.
This works for me on IM 6.7.2.3 Q16 Mac OSX Tiger
# create 8-bit png with transparency
convert logo: -transparent white PNG8:logotp.png
# verify it
Identify -verbose logotp.png
Image: logotp.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: PaletteMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Red:
min: 4 (0.0156863)
max: 255 (1)
mean: 229.323 (0.899307)
standard deviation: 69.3423 (0.271931)
kurtosis: 4.45973
skewness: -2.49768
Green:
min: 0 (0)
max: 255 (1)
mean: 226.217 (0.887127)
standard deviation: 70.8689 (0.277917)
kurtosis: 3.37246
skewness: -2.24758
Blue:
min: 0 (0)
max: 255 (1)
mean: 229.064 (0.898288)
standard deviation: 64.1018 (0.251379)
kurtosis: 4.65272
skewness: -2.42185
Alpha:
min: 0 (0)
max: 255 (1)
mean: 42.2975 (0.165872)
standard deviation: 94.8513 (0.371966)
kurtosis: 1.22759
skewness: -1.79655
# extract the alpha transparency data
convert logotp.png -alpha extract logotp_alpha.png
Re: Problem extracting alpha channel from indexed palette PN
Posted: 2011-09-08T17:45:41-07:00
by glennrp
You would need to convert it to RGBA not RGB
Code: Select all
convert toucan.png png32:toucan_rgba.png
What command did you use to try to extract the alpha channel?
What version of IM do you have?
(BTW: toucan.png is found in the libpng distribution, gregbook directory).
Re: Problem extracting alpha channel from indexed palette PN
Posted: 2011-09-08T18:45:18-07:00
by vtagle-qsi
Doh! The version of ImageMagick I was using was older than I thought (v6.6.something or other). Upgrading to the latest version fixes the problem.