在pdf上插入png后不透明背景

时间:2018-01-03 14:48:52

标签: php image ubuntu pdf imagick

我试图在Ubuntu服务器上使用Imagick在pdf文件上添加png图像。

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

但背景颜色为白色。

Example on Ubuntu Server

有趣的事实是它在Windows上正常工作。

Example on Windows

我正在使用:

  • php7.0-FPM
  • php-imagick 3.4.3

我真的不明白错误的位置。

有没有人有这样的问题?我应该在哪里找到错误?

1 个答案:

答案 0 :(得分:0)

这是我用于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);
相关问题