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
|
// Read image binary data and convert to hex/base64 string
|
||||||
if ($this->sourceType == self::SOURCE_GD) {
|
if ($this->sourceType == self::SOURCE_GD) {
|
||||||
$imageResource = call_user_func($this->imageCreateFunc, $actualSource);
|
$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();
|
ob_start();
|
||||||
call_user_func($this->imageFunc, $imageResource);
|
call_user_func($this->imageFunc, $imageResource);
|
||||||
$imageBinary = ob_get_contents();
|
$imageBinary = ob_get_contents();
|
||||||
|
|||||||
@ -352,6 +352,10 @@ abstract class AbstractWriter implements WriterInterface
|
|||||||
// Retrive GD image content or get local media
|
// Retrive GD image content or get local media
|
||||||
if (isset($element['isMemImage']) && $element['isMemImage']) {
|
if (isset($element['isMemImage']) && $element['isMemImage']) {
|
||||||
$image = call_user_func($element['createFunction'], $element['source']);
|
$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();
|
ob_start();
|
||||||
call_user_func($element['imageFunction'], $image);
|
call_user_func($element['imageFunction'], $image);
|
||||||
$imageContents = ob_get_contents();
|
$imageContents = ob_get_contents();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user