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?".
gohanman
Posts: 3 Joined: 2011-09-16T07:22:19-07:00
Authentication code: 8675308
Post
by gohanman » 2014-06-12T12:13:48-07:00
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?
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2014-06-12T12:18:58-07:00
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.
glennrp
Posts: 1147 Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W
Post
by glennrp » 2014-06-12T12:53:13-07:00
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.