【问题标题】:Setting background color as transparent while creating PNG image from EPS file从 EPS 文件创建 PNG 图像时将背景颜色设置为透明
【发布时间】:2013-09-07 09:52:59
【问题描述】:

我使用 PHP Imagick 处理图像,我需要将 EPS 文件转换为 PNG 文件,接下来剩余的代码可以处理创建的 PNG,我能够将 EPS 转换为 PNG 并可以处理,但是当我这样做时PNG文件是用白色背景创建的,我希望它是透明的,EPS文件也没有任何背景。 我的代码如下

$img = new Imagick();
$img->setResolution(300,300);
$img->readImage('my_file.eps); //reading the file
$img->setBackgroundColor ('#623423'); //setting background color but not working
$img->setImageFormat("png"); //setting the format to save//converting
$img->writeImage('converted.png'); //saving the converted file

但是生成的 png 带有白色背景,有人可以帮助我如何在没有背景颜色(透明)的情况下创建它吗? 提前致谢!

【问题讨论】:

  • 你能提供一个透明的eps图像吗?我找不到它。您是否发现在“my_file.eps”之后缺少引号?

标签: php image-processing imagemagick gd imagick


【解决方案1】:

你看过这个例子吗?

<?php

$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));

$im->readImage('carte_Alain2.svg');

$im->setImageFormat("png32");

header('Content-type: image/png');
echo $im;
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2018-02-23
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 2020-03-03
    • 2011-06-26
    • 2016-08-15
    相关资源
    最近更新 更多