-fill option and 16bit data

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?".
Post Reply
drewvy

-fill option and 16bit data

Post 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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: -fill option and 16bit data

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: -fill option and 16bit data

Post 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.
drewvy

Re: -fill option and 16bit data

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -fill option and 16bit data

Post 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.
drewvy

Re: -fill option and 16bit data

Post by drewvy »

Thank you for your help! Thats exactly what I was missing.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: -fill option and 16bit data

Post 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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply