简体   繁体   中英

Not transparent background after inserting png on pdf

I'm trying to add png image on pdf file using Imagick on Ubuntu Server.

$background = imagecolorallocate($signature_place, 255, 255, 255);
imagefill($signature_place, 0, 0 , $background);
imagecolortransparent($signature_place, $background);

But the background has a dirty white color.

Example on Ubuntu Server

The interesting fact that it works correctly on Windows.

Example on Windows

I'm using:

  • php7.0-fpm
  • php-imagick 3.4.3

I really don't understand where the error could be.

Did anyone have such problem? Where should I find the error?

This is what I use for PNG

    $im = imagecreatefrompng($this->source);
    imagealphablending($newImg, false);
    imagesavealpha($newImg, true);
    $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
    imagefilledrectangle($newImg, 0, 0, $newWidth, $newHeight, $transparent);
    imagecopyresampled($newImg, $im, 0, 0, 0, 0, $newWidth, $newHeight, $this->srcWidth, $this->srcHeight);
    imagepng($newImg, $this->destin);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM