Skip to content

Commit adfcc62

Browse files
committed
imagesavealpha() in Writer\AbstractWriter
1 parent 28f801b commit adfcc62

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/PhpWord/Writer/AbstractWriter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ protected function addFilesToPackage(ZipArchive $zip, $elements)
360360
// Retrive GD image content or get local media
361361
if (isset($element['isMemImage']) && $element['isMemImage']) {
362362
$image = call_user_func($element['createFunction'], $element['source']);
363+
if ($element['imageType'] === 'image/png') {
364+
// PNG images need to preserve alpha channel information
365+
imagesavealpha($image, true);
366+
}
363367
ob_start();
364368
call_user_func($element['imageFunction'], $image);
365369
$imageContents = ob_get_contents();

0 commit comments

Comments
 (0)