Wrong render SVG with hueRotate filter by PHP Imagick

506 views Asked by At

PHP Imagick render wrong colors with SVG feColorMatrix filter. For example I take a blue square and rotate hue by 1 deg. Browser render it right: http://codepen.io/anon/pen/BNwVWK -- I have get blue color.

However, PHP render square wrong in purple color.

$svg = '<?xml version="1.0"?><svg version="1.1" width="100" height="100">
         <defs>
           <filter id="myf">
              <feColorMatrix type="hueRotate" values="1" />
           </filter>
         </defs>
         <rect filter="url(#myf)" width="100" height="100" style="fill:rgb(0,0,230);" />
        </svg>';
$image = new Imagick();
$image->readImageBlob($svg);
$image->setImageFormat("jpeg");
header("Content-Type: image/jpeg");
echo $image->getImageBlob();

Imagic wrong SVG-render

I test this error on different configs with same results:
1. WAMP, PHP 5.4.29, Imagic 3.3.0RC2, ImageMagick 6.8.9-1 Q16 x86, svg delegation: RSVG 2.40.1
2. LAMP, ImageMagic(7.0, latest-master) with native svg render (no svg delegation).

1

There are 1 answers

5
Danack On

I can't reproduce this problem on the latest ImageMagick.

Imagick calls the ImageMagick library to do all it's processing of images. The Image Magick library does not always handle SVGs itself, it can delegate the rendering of them off to another library to process them.

From the command line, if you run convert -list configure you should be able to see what delegates are being used by ImageMagick, under the DELEGATES entry.

If you see Inkscape or RSVG you or other library that is used for SVG processing, you could try upgrading to the latest version of it. If you have no SVG delegate, then you should try the latest version of ImageMagick.