imagick opens svg but only shows certain layers

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Locked
Zword
Posts: 5
Joined: 2020-04-15T11:01:39-07:00
Authentication code: 1152

imagick opens svg but only shows certain layers

Post by Zword »

Hi.
I am new to Imagick, and am trying to convert an svg to a png and resize it in php.
After trying numerous things, I still have an issue with how imagick reads the svg, it only shows the vectorized layers and not the rasterized layers.

This is my code:

Code: Select all

$image = new Imagick();
$image->readImage('./wp-content/uploads/REV-GEN4-NARROW_EVASION_SIDESHOT_FINAL.svg');
$image->setImageFormat("png");
$image->writeImage( "imagetest.png" );
header("Content-type: image/png");
echo $image->getImageBlob();
This is the svg:
Image

And this is what it looks like after Imagick reads it in the above code:
Image

It should instead show everything, what am I doing wrong? Thanks.

I am using imagick module version 3.4.4 and ImageMagick 6.7.2-7
Last edited by Zword on 2020-04-15T20:11:28-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagick opens svg by only shows certain layers

Post by fmw42 »

Post the original SVG file so we can test.

Imagemagick 6.7.2-7 is ancient. You really should upgrade if possible.

The other issue might be the version of the SVG renderer you are using. MSVG is the internal Imagemagick rendered. But Imagemagick can use the RSVG delegate if installed with Imagemagick or it can Inkscape if that is on your system.

Zword
Posts: 5
Joined: 2020-04-15T11:01:39-07:00
Authentication code: 1152

Re: imagick opens svg by only shows certain layers

Post by Zword »

Hi, thanks.
Here is the svg file: http://fxgraphicsgroup.com/wp-content/u ... _FINAL.svg
I'm not sure if upgrading is possible because the site is hosted.
I'm not familiar with what msvg or rsvg or inkscape is, but I'll try to read up on it. thanks.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagick opens svg but only shows certain layers

Post by fmw42 »

It renders fine for me on IM 6.9.11.6 with Inkscape 9.50 installed on my system. Imagemagick will use Inkscape if it is installed (at least in modern versions). What SVG renderer is being used: MSVG/XML, RSVG delete or Inkscape. In the latter two cases, what are the versions.

You can tell if MSVG/XML or RSVG if do

Code: Select all

convert -list format
and look at the end of line for SVG. It will either say RSVG or XML.

MSVG/XML is the Imagemagick internal renderer. It produced a totally white image for me. I do not have RSVG configured at this time.

Zword
Posts: 5
Joined: 2020-04-15T11:01:39-07:00
Authentication code: 1152

Re: imagick opens svg but only shows certain layers

Post by Zword »

Hi, thanks for the help...

The site is hosted on centOS 6. We had them upgrade imagemagick to ImageMagick 7.0.10-6 and imagick module version 3.4.4.
After the upgrade, it now renders as plain white like it did for you. So based on what you said about it working with inkscape, we had them install inkscape, it is the latest version for centOS 6.
https://centos.pkgs.org/6/centos-x86_64 ... 4.rpm.html

Is there something that has to be configured now to make it use the inkscape renderer? I don't have access to bash commands on the server so I can't enter the commands you suggested. We can probably have the hosting company do it though if you have any suggestions on what needs to be done. Thanks again for your help.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagick opens svg but only shows certain layers

Post by fmw42 »

If Inkscape is on the system, Imagemagick should find it if it is in your $PATH environment variable and use it automatically. At least that is my understanding and experience.

Zword
Posts: 5
Joined: 2020-04-15T11:01:39-07:00
Authentication code: 1152

Re: imagick opens svg but only shows certain layers

Post by Zword »

Thanks, how do we tell if it is in our $PATH environment variable? Have the host company do a convert -list format and check the svg line?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagick opens svg but only shows certain layers

Post by fmw42 »

No, I do not think that will work. Put -verbose in your command line. That should tell you if you are using Inkscape.

Zword
Posts: 5
Joined: 2020-04-15T11:01:39-07:00
Authentication code: 1152

Re: imagick opens svg but only shows certain layers

Post by Zword »

So just the command "-verbose"? or add it to another command?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagick opens svg but only shows certain layers

Post by fmw42 »

In your convert command right after convert

Code: Select all

convert -verbose image.svg image.png

Locked