In imageapi_imagemagick_image_rotate() the parameter pipeline for rotating an image is in the wrong order. ImageMagick (6.3.X, and I believe the entire 6.X series) needs the -background parameter before -rotate.
In addition, the type testing for color value need to be test for integer, not numeric as dechex() will fail on string values (or always set it to 0 = black).
This simple patch cleans this up.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | imageapi_373041.patch | 944 bytes | drewish |
| im_rotate_bgcolor.patch | 655 bytes | kaare |
Comments
Comment #1
drewish commentedwhat about checking for is_numeric() then casting to an int?
Comment #2
kaareis_numeric()returns true for all number literals as strings in php. That is, it will return true for all these cases:This means that the test
is_numeric()also accept colors specified as hex string ('0xRRGGBB'). Now, casting this value (same asintval()) will return 0 (This is what PHP does internally with the argument todechex()). Assuming you know it's a hex string, you can runhexdec(), but there is no point in that, as you want a hex representation of the color as a string.I'd like to think that if you get a color, and it already is an integer, it's because it has been specified as PHP hex literals or that it already has been run through
hexdec(). Is it a string, well, then it's in hex of some sort ('#RGB', '0xRRGGBB', 'RGB').Now, as the comment in
imageapi_image_rotate()says, the color parameter should be a hex integer. If it's a string, everything is ok, just strip the '0x' or '#' part in the beginning. If it's a hex literal as integer, test whether it's an integer and rundechex()and everything is ok.Comment #3
drewish commentedthanks for clarifying that. committed to HEAD and DRUPAL-6--1. attaching a clean re-roll.