imagick
imagick copied to clipboard
borderImage with transparent color not working properly in imagick7
borderImage function with any 'transparent' color string makes black corrupted image. any other colors work good
I'm not seeing that. Can you say which version of ImageMagick you're using, and the exact color string you are seeing the problem with, and upload the 'corrupted' image.
'versionNumber' => 1799,
'versionString' => 'ImageMagick 7.0.7-11 Q16 x64 2017-11-23
Here is image, good green border and bad transparent border
For the exact 'color string', please can you give me the precise values you are using for $color, width and height on the line:
$imagick->borderImage($color, $width, $height);
as there are several ways for a color to be considered transparent.
$imagick->borderImage('none', 50, 50); $imagick->borderImage('transparent', 50, 50); $imagick->borderImage('rgba(255,255,255,0)', 50, 50);
noticed that when you do $imagick->borderImage('rgba(255,255,255,0)', 50, 50); alpha channel affects image itself not the border. i think it is the root of the problem.
Yup, that looks like a bug.
For the borderImage operation, there is a composite operator parameter, which is hard-coded to Atop in the source for ImageMagick 7. It appears that this is a poor choice from https://imagemagick.org/script/command-line-options.php#border :
The -border operation is affected by the current -compose setting and assumes that this is using the default 'Over' composition method. It generates an image of the appropriate size colors by the current -bordercolor before overlaying the original image in the center of this net image. This means that with the default compose method of 'Over' any transparent parts may be replaced by the current -bordercolor setting.
It should default to 'Over' and it should be settable through the api.
This probably affects frameImage also...
oh, please can you test this also for the snapshot version of Imagick @myrecs ?
And there is a new function that allows setting the composite method use:
Imagick::borderImageWithComposite(
ImagickPixel|string $border_color,
int $width,
int $height,
int $composite // COMPOSITE_
): bool {}
@Danack with version you have posted (7.1.0-13 Q16 ) - borderImage also not works as it should be, same behaviour as in 7.0.7, nothing changed And borderImageWithComposite - Call to undefined method Imagick::borderImageWithComposite() - it is absent)
Sorry, I screwed up due to tiredness.
I should have tagged the release of Imagick before asking you to test this.