SVG and clipping path

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
JeroenOnline
Posts: 5
Joined: 2019-08-13T10:22:27-07:00
Authentication code: 1152

SVG and clipping path

Post by JeroenOnline »

Hello,

I'm facing trouble with the php imagick conversion of an svg to png. The clippingmask deletes the image completely and replaces it with a black color. When I try the same conversion in say inkscape it works just fine, anybody can help me with this?
Image
SVG: https://pastecloud.net/OsSRON7Zcg

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

Re: SVG and clipping path

Post by fmw42 »

Works fine for me using IM 6.9.10.60 Q16 Mac OSX with Inkscape as the SVG renderer from command line. I see a picture of a baby.

It is likely your SVG renderer. There are 3 possible: ImageMagick default MSVG/XML, RSVG delegate, Inkscape. The latter are better than MSVG. Check which you are using with ImageMagick on Imagick. Or be sure you have a current version of ImageMagick and install Inkscape. ImageMagick will use that if it is found.
JeroenOnline
Posts: 5
Joined: 2019-08-13T10:22:27-07:00
Authentication code: 1152

Re: SVG and clipping path

Post by JeroenOnline »

Thanks for the very quick response, how can I check from PHP wich renderer I'm using? And even better how can I cange which one is being used.

By the way in addition this is the code I use in PHP to create the jpg.

Code: Select all

        $image = new Imagick();
        $image->readImage(storage_path('Geboortekaartje-Octo-1.svg'));
        $image->setImageFormat('jpg');

        file_put_contents(storage_path('Geboortekaartje-Octo-1.jpg'), $image);
And the information from the imagick module used.
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG and clipping path

Post by fmw42 »

Sorry, I am not an expert no Imagick. But if you install Inkscape on the system, then ImageMagick will use it automatically, if it can find Inkscape. The only way to know which renderer is likely to use -verbose in the command line. So use PHP exec() with the command line convert to process your svg file including -verbose in the command line.
JeroenOnline
Posts: 5
Joined: 2019-08-13T10:22:27-07:00
Authentication code: 1152

Re: SVG and clipping path

Post by JeroenOnline »

fmw42 wrote: 2019-08-13T11:16:51-07:00 Sorry, I am not an expert no Imagick. But if you install Inkscape on the system, then ImageMagick will use it automatically, if it can find Inkscape. The only way to know which renderer is likely to use -verbose in the command line. So use PHP exec() with the command line convert to process your svg file including -verbose in the command line.
Allright thank you I just runned the command manually from the command line and it gave me "Aborted" back no further output is my command wrong?

Code: Select all

convert testimage.svg test.png
with the verbose flag

Code: Select all

convert testimage.svg test.png -verbose
gave me aborted aswell.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG and clipping path

Post by fmw42 »

try

Code: Select all

convert -verbose testimage.svg test.png
But if

Code: Select all

convert testimage.svg test.png
aborts, then it would seem that something is wrong with your ImageMagick version install.

What do you get from

Code: Select all

convert -version
If that works, then what do you get for the line starting with SVG in the following result:

Code: Select all

convert -list format
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: SVG and clipping path

Post by snibgo »

JeroenOnline wrote:convert testimage.svg test.png -verbose
The last argument should be the output filename. Not "-verbose" or anything else. Try:

Code: Select all

convert -verbose testimage.svg test.png
snibgo's IM pages: im.snibgo.com
JeroenOnline
Posts: 5
Joined: 2019-08-13T10:22:27-07:00
Authentication code: 1152

Re: SVG and clipping path

Post by JeroenOnline »

Thank you very much both!
fmw42 wrote: 2019-08-13T11:53:17-07:00 try

Code: Select all

convert -verbose testimage.svg test.png
But if

Code: Select all

convert testimage.svg test.png
aborts, then it would seem that something is wrong with your ImageMagick version install.

What do you get from

Code: Select all

convert -version
If that works, then what do you get for the line starting with SVG in the following result:

Code: Select all

convert -list format
Convert verbose gives me:

Code: Select all

 convert -verbose Geboortekaartje-Octo-1.svg test.png
"inkscape" "Geboortekaartje-Octo-1.svg" --export-eps="/tmp/magick-37767nPLbA_doiGwI" --export-dpi="90,90" --export-background="rgb(100%,100%,100%)" --export-background-opacity="1" > "/tmp/magick-37767cbwD7Suw2XNE" 2>&1
Aborted
Convert version:

Code: Select all

 convert -version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2019-06-15 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
And last convert -list format:

Code: Select all

SVG  SVG       rw+   Scalable Vector Graphics (RSVG 2.40.13)
     SVGZ  SVG       rw+   Compressed Scalable Vector Graphics (RSVG 2.40.13)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: SVG and clipping path

Post by snibgo »

wrote:convert -verbose Geboortekaartje-Octo-1.svg test.png
"inkscape" "Geboortekaartje-Octo-1.svg" --export-eps="/tmp/magick-37767nPLbA_doiGwI" --export-dpi="90,90" --export-background="rgb(100%,100%,100%)" --export-background-opacity="1" > "/tmp/magick-37767cbwD7Suw2XNE" 2>&1
Aborted
This suggests Inkscape isn't working properly. Can you run Inkscape interactively? If so, can Inkscape read that SVG and display it? Can you run that Inkscape command from the command line?

Your version on IM creates the Inkscape command to output an EPS file, so this also needs Ghostscript. So it could be a problem with Ghostscript. Is that also installed?
snibgo's IM pages: im.snibgo.com
JeroenOnline
Posts: 5
Joined: 2019-08-13T10:22:27-07:00
Authentication code: 1152

Re: SVG and clipping path

Post by JeroenOnline »

My issue seems to be related to this issue: https://gitlab.com/inkscape/inkscape/issues/294. I'll do some further investigation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG and clipping path

Post by fmw42 »

Try removing and upgrading Inkscape. Be sure it install with no errors and has all needed delegates installed for it.
Post Reply