ryanzec
ryanzec

Reputation: 28060

ImageMagick Convert not generating correct color

When I run this command:

convert -units PixelsPerCentimeter -type TrueColorMatte -channel RGBA -size 32x32 -alpha transparent xc:none -fill "hsla(60 ,83% ,64%)" -draw "circle 15,16 8,10" png32:"/test.png"

I am getting an image with a color of hsla(215,79%,64%,1) instead of hsla(60, 83%, 64%, 1) as specified in the fill argument, am I doing anything wrong?

I am running Mac OS X 10.9 and ImageMagick 6.8.7-7 Q16 x86_64 2013-11-27

Upvotes: 0

Views: 293

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207853

I have tried simplifying your command and re-running it on my OSX Mavericks to see what gives. Basically, I found I could safely remove several things and it made no difference, till I got down to this which still gives the same result as your example (I think):

convert -size 32x32 xc:transparent -fill "hsla(60 ,83% ,64%,1)" -draw "circle 15,16 8,10" png32:a.png

Then I thought about the ranges for each of H, S and L. The range for H is 0-360, and then I realised that your 60 for H is being interpreted as 60% because, with a little rounding error, 60*360/100=215 which is what you are seeing for your H value. So, I changed your H value from 60 to 16 (since 16% of 360 is the 60 you want) and it comes out as the 60 you wanted. Not sure if it is a bug, or what, but I think that is what is happening.

By the way, I note that Fred, on this page, is careful never to mix pure numbers with percentages when specifying HSL colours, so maybe his software doesn't expect us to either...

I am now certain that IM is interpreting your H value as a percentage, if you put in 50, you get out 180 (50% of 360) and if you put in 10, you get out 36 (10% of 360).

Upvotes: 1

Related Questions