Thanks a lot for your reply Anthony.
This has turned into quite a length email chronicling my adventures. One theme
I'm seeing throughout my tests is that I can not get the colorspace to reduce
on my 64bit images without the use of the PNG8: prefix on my image files. I see
no effect when using -colors, -map, -depth, -quantize or any of the other
commands that should alter colorspace. Suggestions?
I tried your suggestion of setting the map parameter but unfortunately, I still
wind up with a 2bit palette. Here's the output from my convert command:
#>convert -verbose plantae_-125_38_-120_34.001.PNG -map netscape:
PNG8:plantae_-125_38_-120_34.001.PNG
plantae_-125_38_-120_34.001.PNG PNG 5001x4000 5001x4000+0+0 DirectClass 16-bit
155.01kb 0.875u 0:01
NETSCAPE GIF 216x144 216x144+0+0 PseudoClass 256c 8-bit 9.55859kb
netscape:=>NETSCAPE NETSCAPE 216x144 216x144+0+0 PseudoClass 256c 8-bit
9.55859kb
plantae_-125_38_-120_34.001.PNG PNG 5001x4000 5001x4000+0+0 PseudoClass 216c
8-bit 7.81641kb 24.094u 0:25
So, it looks like it's being set at 8 bit depth from what the verbose output is
saying, but when I run the identify command I see that it still has the same 2
color colormap. I get the same results when using the colormap_332.png image:
C:\workspace\vdm\snapshot_creator\test_8bit>identify -verbose
plantae_-125_38_-120_34.001.PNG
Image: plantae_-125_38_-120_34.001.PNG
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 5001x4000+0+0
Type: Palette
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 1-bit
Green: 1-bit
Blue: 1-bit
Channel statistics:
Red:
Min: 0 (0)
Max: 1 (1)
Mean: 1.12977e-005 (1.12977e-005)
Standard deviation: 0.00336119 (0.00336119)
Green:
Min: 0 (0)
Max: 0 (0)
Mean: 0 (0)
Standard deviation: 0 (0)
Blue:
Min: 0 (0)
Max: 0 (0)
Mean: 0 (0)
Standard deviation: 0 (0)
Colors: 2
Histogram:
20003774: #000000 black
226: #FF0000 red
Colormap: 4
0: #000000 black
1: #FF0000 red
2: #FFFFFF white
3: #FFFFFF white
Rendering intent: Undefined
Resolution: 72x72
Units: Undefined
Filesize: 7.81641kb
Interlace: None
Background color: rgb(1,1,1)
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Page geometry: 5001x4000+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Signature: 8b041ffa595b17166e6abbe48683ad08da65b495fd56f57d9a18a552dd999c40
Profile-icc: 3144 bytes
For comparison, this is a 2-color image that I saved in irfanview with colors
set to 256, I've tried using this file as the colormap as well, but get the
same results.
#>identify -verbose rovcoverage_TiburonCleanNavData_20_20_test256.png
Image: rovcoverage_TiburonCleanNavData_20_20_test256.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 5001x4001+0+0
Type: PaletteMatte
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit
Channel statistics:
Red:
Min: 4 (0.0156863)
Max: 4 (0.0156863)
Mean: 4 (0.0156863)
Standard deviation: 0 (0)
Green:
Min: 2 (0.00784314)
Max: 2 (0.00784314)
Mean: 2 (0.00784314)
Standard deviation: 0 (0)
Blue:
Min: 4 (0.0156863)
Max: 252 (0.988235)
Mean: 4.04983 (0.0158817)
Standard deviation: 3.51486 (0.0137838)
Alpha:
Min: 255 (1)
Max: 0 (0)
Mean: 0.0512319 (0.00020091)
Standard deviation: 3.61407 (0.0141728)
Alpha: rgba(4,2,4,0) #04020400
Colors: 2
Histogram:
20004981: #04020400 rgba(4,2,4,0)
4020: #0402FC rgb(4,2,252)
Rendering intent: Undefined
Resolution: 0.79x0.79
Units: PixelsPerCentimeter
Filesize: 25.1582kb
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: none
Page geometry: 5001x4001+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Signature: 7eeaf640537829dff823feaf1ea59cbe478c12dde1f884a9c74c6978a12e4d6e
An additional quirk I'm not understanding (as mentioned above), is that if I
don't specify PNG8: in front of my output image, I'm not seeing any reduction
in the color depth at all, regardless of other options I'm passing in (depth,
colormap, colors, etc).
Can anyone suggest a decent programming API for manipulating png images? I'm
beginning to think it might be easier to write a little code that took a 2bit
depth and converted it to 8bit.
Cheers,
Andrew
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Anthony Thyssen
> Sent: Thursday, March 08, 2007 11:09 PM
> To: ImageMagick User List
> Subject: Re: [magick-users] How do I lock color depth at a
> minimum level?
>
> "Chase, Andrew" on wrote...
> | Hi Folks,
> |
> | I'm working with png images that are only two colors, black and red.
> | I'm using a palette and setting the black to be
> transparent. I start
> | out with 24bit images and am trying to use the convert tool
> to change
> | them to 8bit images. I'm using the following command:
> |
> | convert myFile.png PNG8:myFile.png
> |
> PNG8 is basically GIF color handling encoded into PNG.
> I'll treat this as
> convert myFile.png myFile.gif
> instead.
>
> | I've tried various options such as the -depth flag, -colors
> flag, and
> | any other flag that looked like it would lock the bit
> depth. However,
> | whatever I do, I always end up with an image with 2 bits per pixel
> | rather than 8.
> |
> bit depth does not get used for GIF or PNG8. it is more for
> things with variable depth like raw RGB, TXT, PPM, etc...
>
> For PNG8 and GIF IM always uses the minimum color table (power of 2 in
> size) needed to hold the number of colors in the image.
>
> You are the first to request something other than this.
>
> | Unfortunately, the program I'm displaying the png's in
> really doesn't
> | like images with less that 8bits. Does anybody know how to
> force this
> | option?
> |
> Then don't use PNG8 as IM uses 8bit colors in a 8bit color index.
>
> PNG has lots of formating controls, not all implemented.
> Many such controls may even be undocumented. (the -define controls)
>
> I have tried to document them as I see them but there is not
> formal source of info, other than the source code itself for this :-(
>
> Usally things get added as users request them and Cristy has time.
>
> | If I open the file in IrfanView and then save it in
> IrfanView it comes
> | out with the correct 8 bit pixels, so I know it's possible.
> |
> Okay you always want a 256 color table.
>
> One thing you can TRY (may not work) is to give the image a
> fixed -map of 256 colors, including red and black. You could try the
> colormap_332.png
> image create in IM examples. (256 colors, no transparency)
> http://www.imagemagick.org/Usage/quantize/#map_colormaps
>
> Or even the builtin netscape: color map (219 colors)
>
> Anthony Thyssen ( System Programmer ) <[EMAIL PROTECTED]>
>
> --------------------------------------------------------------
> ---------------
> Okay, who stopped the payment on my reality check? -- A
> Bumper Sticker
>
> --------------------------------------------------------------
> ---------------
> Anthony's Home is his Castle
> http://www.cit.gu.edu.au/~anthony/
> _______________________________________________
> Magick-users mailing list
> [email protected]
> http://studio.imagemagick.org/mailman/listinfo/magick-users
>
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users