Page 1 of 1

-fill option and 16bit data

Posted: 2008-07-08T09:35:55-07:00
by drewvy
I want to create a 16bit image with a single color. I've been using -fill and -draw to do this but I can't seem to get the exact 16bit color I want. Does -fill only take in 8 bit values? It seems that if you use -fill on a 16bit image, it will scale it to something close to the 16 bit value but I can't get the exact values I need.

~Drew

Re: -fill option and 16bit data

Posted: 2008-07-08T10:31:02-07:00
by el_supremo
I'm using the 8-bit version of IM, but if I do:

Code: Select all

convert -size 640x480 xc:rgb(120,180,50) test.png
the pixels are all the correct colour.

However, if I do this:

Code: Select all

convert -size 640x480 xc:rgb(120,180,50) test.jpg
the pixels are actually rgb(120,179,50)

So, if you're saving the image as a jpg, try it as png instead.

Pete

Re: -fill option and 16bit data

Posted: 2008-07-08T11:46:46-07:00
by Bonzo
I think something similar to this came up before and it was blamed on jpg compression?
The conclusion was as Pete sugested save as a png instead.

Re: -fill option and 16bit data

Posted: 2008-07-08T12:22:03-07:00
by drewvy
If I run this...

convert blue.tif -fill rgb(1,2,300) -draw "rectangle 0,0 1920,1080" newblue.tif

blue.tif is a 16bit color image. newblue ends up as a solid color of RGB: 257, 514, 65535


what I really want to do is this:
convert blue.tif -fill rgb(13050, 50000, 33333) -draw "rectangle 0,0 1920,1080" newblue.tif

but newblue ends up as a solid color of RGB: 65535, 65535, 65535

Re: -fill option and 16bit data

Posted: 2008-07-08T12:37:15-07:00
by magick
Read http://www.imagemagick.org/script/color.php. If you want to use rgb() you need to specify percentages to generate 16-bit values. You can also use hex color numbers, for example, #123412341234.

Re: -fill option and 16bit data

Posted: 2008-07-08T12:55:46-07:00
by drewvy
Thank you for your help! Thats exactly what I was missing.

Re: -fill option and 16bit data

Posted: 2008-07-08T22:37:43-07:00
by anthony
Additional note. The percentages are floating point values, so you can add some decimal places to get exactly the color wanted.

Also be sure to add -depth 16 even on a IM Q16 version, as this ensures that the output will be an 16 bit image, and not re-saved as 8-bit if the source image was 8 bit (like an 8bit color canvas)