I defined a rotate effect with an empty background. According to the on-screen help and the GD implementation this should give me a transparent background (in the corner triangles). however the imagick toolkit results in an image with the triangles coloured according to the cornel pixel colors.
I fixed this as below in the given function. Note that in that function there were also references to the not initialized variable $bgcolor whereas $background (the parameter) should have been used.
file: imageapi_imagemagick.module
function: image_imageapi_imagemagick_rotate
new code:
function image_imageapi_imagemagick_rotate(stdClass $image, $degrees, $background = NULL) {
if (is_null($background)) {
$bgcolor = 'transparent';
} elseif (is_int($background)) {
$bgcolor = '#'. str_pad(dechex($background), 6, 0);
} else {
$bgcolor = str_replace('0x', '#', $background);
}
$image->ops[] = '-background '. escapeshellarg($bgcolor) .' -rotate '. (float) $degrees;
return TRUE;
}
Perhaps the literal string transparent should be replaced by something like rgba(0,0,0,0.0) as I'm not sure that transparent will be defined (in colors.xml) in all (supported) installations/versions.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1021850-4.patch | 1.22 KB | fietserwin |
| #1 | 1021850.patch | 901 bytes | fietserwin |
Comments
Comment #1
fietserwinAnd as a patch (against the 7.x-1.x-dev 2010-Oct-18 version).
Comment #2
sunComment #3
fietserwinLooks like it has been added to the dev version?!
Comment #4
fietserwinThe "-background transparent" option is necessary as actions earlier on the command line may already have used the -background option. Thus the original code works better in combination with other commands.
Comment #5
sunThis looks good. I merely wonder what happens if the image format doesn't support transparency? Or do we simply don't care about that and leave it to effect configuration to figure out?
Comment #6
fietserwinWell, the background color is entered by the user/admin defining the style. We may assume that (s)he knows what (s)he's doing and doesn't fill in transparent (or leaves the field empty) with, e.g., a jpg format. Thus I think we shouldn't care (as imagemagick also doesn't).
Comment #7
sunThanks for reporting, reviewing, and testing! Committed and pushed to 7.x-1.x.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.