【问题标题】:Not transparent background after inserting png on pdf在pdf上插入png后背景不透明
【发布时间】:2018-01-03 14:48:51
【问题描述】:

我正在尝试在 Ubuntu Server 上使用 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

我真的不明白错误可能出在哪里。

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

【问题讨论】:

    标签: php image ubuntu pdf imagick


    【解决方案1】:

    这是我用于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);
    

    【讨论】:

      猜你喜欢
      • 2013-12-10
      • 2011-12-04
      • 1970-01-01
      • 2012-12-22
      • 1970-01-01
      • 2012-02-26
      • 2017-10-11
      • 2012-06-26
      • 2012-12-13
      相关资源
      最近更新 更多