我使用imagick检查的图像中PHP这样的格式:Imagick :: getImageFormat返回“PNG”为SVG
$image = new Imagick('simple.svg');
echo $image->getImageFormat();
令我惊喜,输出为PNG
,即使Imagick::queryFormats()
名单SVG
作为已知类型。 一切从Apache的,到PHP,到imagick应是最新(新安装):
PHP Version 7.0.8-0ubuntu0.16.04.3
----------------------------------------------------------------------
imagick module version 3.4.0RC6
Imagick compiled with ImageMagick version ImageMagick 6.8.9-9 Q16 x86_64 2016-03-14
Imagick using ImageMagick library version ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29
ImageMagick release date 2016-11-29
我已经尝试了不同的.SVG文件,所有返回PNG
。我试过的一个简单的svg文件来自Wikipedia here。任何想法为什么imagick返回一个错误的格式?像JPG和PNG格式的图像被正确检测。
编辑:
使用Imagick::pingImage
前Imagick::identifyImage
回报PNG以及:
[mimetype] => image/png
[format] => PNG (Portable Network Graphics)
[units] => Undefined
[type] => Bilevel
[colorSpace] => Gray
[compression] => Undefined
[fileSize] => 7.05KB
[geometry] => Array ([width] => 320 [height] => 372)
[resolution] => Array ([x] => 72 [y] => 72)
的.svg文件绝对不是PNG:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="480" height="543.03003" viewBox="0 0 257.002 297.5" xml:space="preserve">
<g transform="matrix(0.8526811,0,0,0.8526811,18.930632,21.913299)">
<polygon points="8.003,218.496 0,222.998 0,74.497 8.003,78.999 8.003,218.496 "/>
<polygon points="128.501,287.998 128.501,297.5 0,222.998 8.003,218.496 128.501,287.998 " />
<polygon points="249.004,218.496 257.002,222.998 128.501,297.5 128.501,287.998 249.004,218.496 " />
<polygon points="249.004,78.999 257.002,74.497 257.002,222.998 249.004,218.496 249.004,78.999 " />
<polygon points="128.501,9.497 128.501,0 257.002,74.497 249.004,78.999 128.501,9.497 " />
<polygon points="8.003,78.999 0,74.497 128.501,0 128.501,9.497 8.003,78.999 " />
</g>
</svg>
Imagemagick使用光栅图像;我想知道svg是否在阅读时转换?你可以使用Imagick :: pingImage来ping图像我不知道会返回什么。 – Bonzo
我尝试了ping和'identifyImage',结果在我的原始文章中。 – user7367183
使用当前的ImageMagick-7.0.4-1,'magick identify * .svg'返回 file.svg SVG 480x543 480x543 + 0 + 0 16位sRGB 813B 0.000u 0:00.079 –