Page 1 of 1

Resize PNG ignores specified depth

Posted: 2014-06-12T12:13:48-07:00
by gohanman
I have a PNG with 1-bit color. I'm trying to resize it. Identify shows this for the original:

Code: Select all

  Format: PNG (Portable Network Graphics)
  Class: PseudoClass
  Geometry: 180x192
  Type: Bilevel
  Endianess: Undefined
  Colorspace: Gray
  Channel depth:
    Gray: 1-bits
  Channel statistics:
    Gray:
      Min: 0 (0)
      Max: 1 (1)
      Mean: 0.596644 (0.596644)
      Standard deviation: 0.490571 (0.490571)
  Colors: 2
If I resize it like this:

Code: Select all

convert -resize x115 -depth 1 original.png smaller.png
The resulting file looks like this:

Code: Select all

  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 108x115
  Type: Grayscale
  Endianess: Undefined
  Colorspace: Gray
  Channel depth:
    Gray: 8-bits
  Channel statistics:
    Gray:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 152.01 (0.596119)
      Standard deviation: 116.442 (0.456636)
  Colors: 246
How do I resize the image while retaining 1-bit depth?

Re: Resize PNG ignores specified depth

Posted: 2014-06-12T12:18:58-07:00
by snibgo
The correct order for commands is in the logical chronological order. In this case: read the image, resize it, set the depth, write it. Try that.

Re: Resize PNG ignores specified depth

Posted: 2014-06-12T12:53:13-07:00
by glennrp
If you "resize" an image there are likely to be more colors in the output than in the input due to interpolation. Use "-sample" to avoid adding colors and
then you shouldn't need to specify the depth.