Merge pull request #779 from samsullivan/imagesavealpha
Save PNG alpha information when using remote images.
This commit is contained in:
commit
fd127ef9bb
|
|
@ -334,6 +334,10 @@ class Image extends AbstractElement
|
|||
// Read image binary data and convert to hex/base64 string
|
||||
if ($this->sourceType == self::SOURCE_GD) {
|
||||
$imageResource = call_user_func($this->imageCreateFunc, $actualSource);
|
||||
if ($this->imageType === 'image/png') {
|
||||
// PNG images need to preserve alpha channel information
|
||||
imagesavealpha($imageResource, true);
|
||||
}
|
||||
ob_start();
|
||||
call_user_func($this->imageFunc, $imageResource);
|
||||
$imageBinary = ob_get_contents();
|
||||
|
|
|
|||
|
|
@ -352,6 +352,10 @@ abstract class AbstractWriter implements WriterInterface
|
|||
// Retrive GD image content or get local media
|
||||
if (isset($element['isMemImage']) && $element['isMemImage']) {
|
||||
$image = call_user_func($element['createFunction'], $element['source']);
|
||||
if ($element['imageType'] === 'image/png') {
|
||||
// PNG images need to preserve alpha channel information
|
||||
imagesavealpha($image, true);
|
||||
}
|
||||
ob_start();
|
||||
call_user_func($element['imageFunction'], $image);
|
||||
$imageContents = ob_get_contents();
|
||||
|
|
|
|||
Loading…
Reference in New Issue