I need same output from Inkscape and Imagick.
我需要从Inkscape和Imagick中获得相同的输出。
This is the expected result, exported from Inkscape.
这是预期的结果,从墨水风景出口。
However, the PHP code below outputs the following faulty result.
但是,下面的PHP代码输出如下错误的结果。
PHP code:
PHP代码:
<?php
$im = new Imagick();
$im->setResolution(400,400);
$im->setBackgroundColor(new ImagickPixel('transparent'));
$im->readImageBlob(str_replace(array("color1", "color2"), array("yellow", "blue"), file_get_contents("img.svg")));
$im->setImageFormat("png");
header("Content-type: image/png");
echo $im;
?>
SVG code:
SVG代码:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="400" height="400">
<rect width="100%" height="100%" fill="green" />
<path d="M250 150 L150 350 L350 350 Z" opacity="0.9" fill="color1" />
<path d="M150 50 L50 250 L250 250 Z" opacity="0.9" fill="color2" />
</svg>
3 个解决方案
#1
1
What version of PHP and ImageMagick are you running? Please share the relevant output of phpinfo()
. Could this ImageMagick bug be affecting you? Or if you're not up to date, could another ImageMagic bug be affecting you?
您正在运行哪个版本的PHP和ImageMagick ?请分享phpinfo()的相关输出。这个ImageMagick bug会影响你吗?或者如果你不最新,另一个ImageMagic bug会影响你吗?
EDIT: I don't have easy access to a server with PHP's ImageMagick libraries installed at the moment, but if I find one, I'll test the code provided and post my results.
编辑:我目前无法轻松访问安装了PHP ImageMagick库的服务器,但如果找到了,我将测试提供的代码并发布结果。
EDIT2: Looks like others have the same issue, unless that forum post was also yours...
看起来其他人也有同样的问题,除非那个论坛帖子也是你的。
According to this forum post, you could try:
根据这篇论坛文章,你可以试试:
$im->setImageFormat("png32");
One person reported that worked, but another said it did not...
有一个人说这种方法有效,但另一个人说没有……
#2
0
Inkscape uses the not ubiquitously supported opacity
property. Use fill-opacity
and stroke-opacity
instead.
Inkscape使用不受普遍支持的不透明属性。使用填充-不透明度和笔划-不透明度代替。
#3
0
This is already fixed in current version of Imagick.
这已经在当前版本的Imagick中得到了修正。
#1
1
What version of PHP and ImageMagick are you running? Please share the relevant output of phpinfo()
. Could this ImageMagick bug be affecting you? Or if you're not up to date, could another ImageMagic bug be affecting you?
您正在运行哪个版本的PHP和ImageMagick ?请分享phpinfo()的相关输出。这个ImageMagick bug会影响你吗?或者如果你不最新,另一个ImageMagic bug会影响你吗?
EDIT: I don't have easy access to a server with PHP's ImageMagick libraries installed at the moment, but if I find one, I'll test the code provided and post my results.
编辑:我目前无法轻松访问安装了PHP ImageMagick库的服务器,但如果找到了,我将测试提供的代码并发布结果。
EDIT2: Looks like others have the same issue, unless that forum post was also yours...
看起来其他人也有同样的问题,除非那个论坛帖子也是你的。
According to this forum post, you could try:
根据这篇论坛文章,你可以试试:
$im->setImageFormat("png32");
One person reported that worked, but another said it did not...
有一个人说这种方法有效,但另一个人说没有……
#2
0
Inkscape uses the not ubiquitously supported opacity
property. Use fill-opacity
and stroke-opacity
instead.
Inkscape使用不受普遍支持的不透明属性。使用填充-不透明度和笔划-不透明度代替。
#3
0
This is already fixed in current version of Imagick.
这已经在当前版本的Imagick中得到了修正。