Page 1 of 1

Reducing color depths

Posted: 2007-07-05T21:44:28-07:00
by drscience
I need to convert an image with 24 bit color to 18 bit color and, just to make things more difficult, I need this conversion to not be dithered.

I looked through the documentation and I just can't figure out how to do this (assuming it can be done).

I searched through the old posts and found this thread that I thought was just what I was looking for, so I tried this:

Code: Select all

convert image1.bmp -fx 'p/4' -fx 'p*4' image2.bmp
The output I got didn't look any different (my test image was a 24bit gradient, so it should have been obvious). Just to be sure, I tried reducing the color depth much further (3 bit/channel color!) and it was still unchanged.

If somebody could explain how/whether this can be done with Image Magick I would be extremely grateful. I'd rather not spend the time writing a program to do this myself.

Re: Reducing color depths

Posted: 2007-07-06T12:02:49-07:00
by drscience
Okay, nevermind, the above commands do indeed work for what I needed. I don't know why I thought they didn't yesterday. Thanks anyways though :)

Re: Reducing color depths

Posted: 2007-07-09T00:45:56-07:00
by anthony
You can also use -fx 'int(u*MaxRGB/4)*4/MaxRGB'
The MaxRGB means use the compiled depth of the image. if you want 6 bit use
256 for that value. EG -fx 'int(u*64)/64'

OR you can use faster -evaluate function
-evaluate multiply .25 -evaluate multiply 4