Mobile app version of vmapp.org
Login or Join
Barnes313

: Convert 8bit sRGB to 4bit grayscale with ImageMagick I want to print an 8bit sRGB PNG image on an Epson TM-T88v receipt printer. The printer needs a 4bit grayscale PNG file to print it correctly.

@Barnes313

Posted in: #FileConversion #Imagemagick #Png

I want to print an 8bit sRGB PNG image on an Epson TM-T88v receipt printer. The printer needs a 4bit grayscale PNG file to print it correctly.

As I'm using PHP with ImageMagick, I'm not sure which commands are needed to convert the image.

If I use ImageMagick's "identify" and "convert" on the linux console on the 8bit input image I get following output:


test.png PNG 128x128 128x128+0+0 8-bit sRGB 1.78KB 0.000u 0:00.000



I've tried...

convert test.png -depth 4 -colorspace gray test-4bit.png


which gives me still an 8bit image instead of 4bit


test-4bit.png PNG 128x128 128x128+0+0 8-bit sRGB 2.58KB 0.000u 0:00.000



Any suggestions?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Barnes313

1 Comments

Sorted by latest first Latest Oldest Best

 

@Turnbaugh909

No idea why but identify seems to always assume sRGB. Your image should actually be grayscale. If you use the -verbose option it will report the correct color space.

For the bit-depth you need to explicitly set the color-type and bit-depth for the PNG encoder by using -define.

This should work:

convert test.png -depth 4 -colorspace gray -define png:color-type=0 -define png:bit-depth=4 test-4bit-gray.png

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme