Skip to content

Commit f4ec74a

Browse files
committed
imagesavealpha() in Element\Image
1 parent adfcc62 commit f4ec74a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/PhpWord/Element/Image.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ public function getImageStringData($base64 = false)
335335
// Read image binary data and convert to hex/base64 string
336336
if ($this->sourceType == self::SOURCE_GD) {
337337
$imageResource = call_user_func($this->imageCreateFunc, $actualSource);
338+
if ($this->imageType === 'image/png') {
339+
// PNG images need to preserve alpha channel information
340+
imagesavealpha($imageResource, true);
341+
}
338342
ob_start();
339343
call_user_func($this->imageFunc, $imageResource);
340344
$imageBinary = ob_get_contents();

0 commit comments

Comments
 (0)