8-bit palleted png, remove alpha

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
jmaeding
Posts: 54
Joined: 2006-05-03T09:48:26-07:00

8-bit palleted png, remove alpha

Post by jmaeding »

I thought it better to make this a new post from the last one on how to recognize 8 bit palletted image.
So in my tests, I ran across an image that has an alpha channel.
I want to get rid of that channel, and have the final image still be 8 bit indexed.
Everything i try ends me up with a non-indexed RGB file, though it does remove the alpha.
I tried -channel RGB, -type, -depth, +matte...
I need some help because I think I am misunderstanding what i am reading on the alpha channel.
The identify -verbose on the original png gives this:
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 1280x853+0+0
Resolution: 72x72
Print size: 17.7778x11.8472
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
James Maeding
Civil Engineer / Programmer
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: 8-bit palleted png, remove alpha

Post by fmw42 »

Are you just trying to turn off the alpha to remove it and convert to palette (pseudocolor) with no alpha channel? What class and type is your input from the verbose info? What version of IM are you using?

Perhaps you need to post a link to your image.

But try

convert image -alpha off -type palette result

or

convert image +matte -type palette result
jmaeding
Posts: 54
Joined: 2006-05-03T09:48:26-07:00

Re: 8-bit palleted png, remove alpha

Post by jmaeding »

I have the latest IM ImageMagick-6.6.5-Q8, running on win 7 64 bit.
I tried the -alpha off -type palette, with same end result - a non paletted 24 bit RGB image.
-verbose gives:
Image: C:\+Storage\Programming\DotNet\RightClickToolsCS\GIMP Scripts\dogmatte.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 1280x853+0+0
Resolution: 72x72
Print size: 17.7778x11.8472
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: 11 (0.0431373)
max: 252 (0.988235)
mean: 129.682 (0.508556)
standard deviation: 61.7109 (0.242003)
kurtosis: -0.803558
skewness: -0.0717212
Green:
min: 5 (0.0196078)
max: 250 (0.980392)
mean: 115.528 (0.45305)
standard deviation: 64.7401 (0.253883)
kurtosis: -0.733158
skewness: 0.178653
Blue:
min: 6 (0.0235294)
max: 254 (0.996078)
mean: 114.825 (0.450296)
standard deviation: 69.1829 (0.271306)
kurtosis: -0.872756
skewness: 0.208371
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
Image statistics:
Overall:
min: 0 (0)
max: 254 (0.996078)
mean: 90.0088 (0.352976)
standard deviation: 56.5371 (0.221714)
kurtosis: 3.56909
skewness: 0.824787
Histogram:
2713: ( 11, 7, 6,255) #0B0706 rgba(11,7,6,1)
...(clipped a bunch of these)....
1917: (252,233,233,255) #FCE9E9 rgba(252,233,233,1)
532: (252,242,236,255) #FCF2EC rgba(252,242,236,1)
Rendering intent: Perceptual
Gamma: 0.45455
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: rgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Compose: Over
Page geometry: 1280x853+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2010-11-19T13:28:19-08:00
date:modify: 2008-11-20T13:17:08-08:00
signature: 73786d9c934fb755a972464febe789cd34c40f2345a31ebfb38f2c68822175eb
Artifacts:
verbose: true
Tainted: False
Filesize: 277KBB
Number pixels: 1.092MB
Pixels per second: 23.73MB
User time: 0.078u
Elapsed time: 0:01.046
Version: ImageMagick 6.6.5-8 2010-11-10 Q8 http://www.imagemagick.org

now, I know the Directclass class is a dead giveaway that the image is not paletted, but the type is palettematte.
When I open in Corel PP, the image comes up listed as 8 bit paletted, but the image is "floating", as if it was selected, cut, and paste back as a layer.
I have to run the "combine objects with background" to unfloat it.
So i get the feeling the image is in two parts, the background and the 8 bit image.
Not sure how to post the image, I don't have a web site set up for it.
James Maeding
Civil Engineer / Programmer
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: 8-bit palleted png, remove alpha

Post by fmw42 »

You do have a palette image as far a I can tell with a fully opaque alpha channel.

Class: DirectClass
Geometry: 1280x853+0+0
Resolution: 72x72
Print size: 17.7778x11.8472
Units: Undefined
Type: PaletteMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit

The type is PaletteMatte which means your image is palette with an alpha channel.

I am not sure why IM reports


Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit

alpha: 1-bit


Perhaps it does that to report the equivalent RGB value below that.

You could post your command and a link to your input and output images. Then others could examine them further.

I don't know for sure, but exifinfo may give you independent information to corroborate if it is indeed palette.

I am not sure why the alpha channel is still around, but it is at least opaque.
Post Reply