Hello. I am trying to use ImageMagic to reduce some 256 color images to 16 color images.
I can use -colors 16 or -posterize 16 and I can get images that have been correctly reduced to 16 colors, but they are still saved with 8 bit bit depth, not 4-bit bit depth. I have tried BMP and PNG, both of which do support 4-bit images, but neither works. I still end up with an 8-bit image.
I tried -depth 4 but it doesn't seem to have any effect.
I can do this manually with the gimp, but it takes forever with a large number of images :(
Does anybody know if ImageMagic is actually capable of writing 4 bit BMP or PNG?
Is there any way to create 4-bit BMP or PNG files with IM?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is there any way to create 4-bit BMP or PNG files with IM?
I cannot say for sure what is up to date, but see http://www.imagemagick.org/Usage/formats/#bmp
" IM can not produce BMP's at depth levels other than 8. However you can
use NetPBM image processing set to do the final conversion to other depth
levels (This needs at least a Q16 version of IM)...
convert image +matte -colors 16 ppm:- |\
pnmdepth 4 | ppm2bmp > image.bmp
Format limitations....
The header for a BMP2: format only allows the description of the width,
height and bit depth (bits per pixel) of an image. The bit depth can be one of
1, 4, 8 or 24.
For comparison, the bmp3: format allows bit depths of 0, 1, 4, 8 ,16, 24 and
32 and has extra fields which specify x and y resolution (in pixels per metre)
and compression of the image data."
I also tried:
convert rose: -depth 4 BMP3:rose.bmp
identify -verbose rose.bmp
Image: rose.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 70x46+0+0
Resolution: 28.34x28.34
Print size: 2.47001x1.62315
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Depth: 8/4-bit
Channel depth:
red: 4-bit
green: 4-bit
blue: 4-bit
Don't know if this is what you need or not?
" IM can not produce BMP's at depth levels other than 8. However you can
use NetPBM image processing set to do the final conversion to other depth
levels (This needs at least a Q16 version of IM)...
convert image +matte -colors 16 ppm:- |\
pnmdepth 4 | ppm2bmp > image.bmp
Format limitations....
The header for a BMP2: format only allows the description of the width,
height and bit depth (bits per pixel) of an image. The bit depth can be one of
1, 4, 8 or 24.
For comparison, the bmp3: format allows bit depths of 0, 1, 4, 8 ,16, 24 and
32 and has extra fields which specify x and y resolution (in pixels per metre)
and compression of the image data."
I also tried:
convert rose: -depth 4 BMP3:rose.bmp
identify -verbose rose.bmp
Image: rose.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 70x46+0+0
Resolution: 28.34x28.34
Print size: 2.47001x1.62315
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Depth: 8/4-bit
Channel depth:
red: 4-bit
green: 4-bit
blue: 4-bit
Don't know if this is what you need or not?
Re: Is there any way to create 4-bit BMP or PNG files with IM?
Thanks! That is just what I needed.
The binary appears to be ppmtobmp not ppm2bmp, but other than that it seems to work great.
The binary appears to be ppmtobmp not ppm2bmp, but other than that it seems to work great.