Page 1 of 1

Convert SVG with clippath to PNG

Posted: 2013-07-24T22:24:32-07:00
by anaiappan
Hi,

I am using imagemagick 6.8 to convert a svg with clip path to PNG. i have tried the following command

/usr/local/bin/convert page_1_g_0.svg -clip /tmp/page_1.png .

But it throws an error like this:
convert: no clip path defined `page_1_g_0.svg': No such file or directory @ error/image.c/ClipImagePath/719.

But my SVG has clip-paths

thanks,
Anaiappan

Re: Convert SVG with clippath to PNG

Posted: 2013-07-24T23:02:59-07:00
by fmw42
I believe you have to convert the clip-path to a clip-mask and then use that. But I am not sure it works except for tiff files. I am not an expert on this.

see
http://www.imagemagick.org/Usage/masking/#clip_mask

Best to provide your svg file so others can test with it.

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T00:00:45-07:00
by anaiappan

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T09:28:47-07:00
by fmw42
I do not know enough about clip-paths to really help. But I get error messages when just trying to convert to png. I am using IM's internal MSVG. Perhaps using the delegate RSVG might work better. But I do not have it installed.

convert page_1_g_0.svg 1tmp1.png
convert: unable to open image `img-1_0.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_0.png' @ error/png.c/ReadPNGImage/3994.
convert: unable to open image `img-1_1.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_1.png' @ error/png.c/ReadPNGImage/3994.
convert: unable to open image `img-1_2.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_2.png' @ error/png.c/ReadPNGImage/3994.



convert page_1_g_0.svg -clip 1tmp1.png
convert: unable to open image `img-1_0.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_0.png' @ error/png.c/ReadPNGImage/3994.
convert: unable to open image `img-1_1.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_1.png' @ error/png.c/ReadPNGImage/3994.
convert: unable to open image `img-1_2.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_2.png' @ error/png.c/ReadPNGImage/3994.
convert: no clip path defined `page_1_g_0.svg': No such file or directory @ error/image.c/ClipImagePath/719.
convert: unable to open image `img-1_0.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_0.png' @ error/png.c/ReadPNGImage/3994.
convert: unable to open image `img-1_1.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_1.png' @ error/png.c/ReadPNGImage/3994.
convert: unable to open image `img-1_2.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: unable to open file `img-1_2.png' @ error/png.c/ReadPNGImage/3994.
convert: no clip path defined `page_1_g_0.svg': No such file or directory @ error/image.c/ClipImagePath/719.

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T09:42:11-07:00
by anaiappan
please use this link:
http://www.fileconvoy.com/dfl.php?id=g0 ... 5a5c8d100c
to download the other images that are mentioned in the SVG

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T09:51:17-07:00
by fmw42
anaiappan wrote:please use this link:
http://www.fileconvoy.com/dfl.php?id=g0 ... 5a5c8d100c
to download the other images that are mentioned in the SVG
These are all PNG files. What do they have to do with the SVG problem and clip paths?

The issue is whether IM can extract and use a clip path from anything other than TIFF, in particular, from an SVG.

I do not know that answer. One of the IM developers would need to answer that. That was why I had you post the SVG file, so they can check that out. Perhaps it is malformed or IM cannot extract the clip path from it.

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T10:02:43-07:00
by anaiappan
My svg has image elements(https://developer.mozilla.org/en-US/doc ... _Image_Tag) also. Thats why it's failed for you with missing image error..

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T11:09:30-07:00
by fmw42
Are you using RSVG or the IM MSVG?

Type

convert -list format

and see what you have listed for SVG. Does is say RSVG?

I am not using it so mine says


SVG SVG rw+ Scalable Vector Graphics (XML 2.8.0)


It would also be listed as a delegate when you do

convert -version
Version: ImageMagick 6.8.6-7 2013-07-25 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib mpeg fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr lzma openexr png ps tiff x xml zlib

If you do not see RSVG, then get the delegate library and install it and recompile IM from source.

See if that works better. IM's MSVG is pretty basic, only. see http://www.imagemagick.org/Usage/draw/#svg_drivers

Re: Convert SVG with clippath to PNG

Posted: 2013-07-25T12:42:30-07:00
by snibgo
"-clip" restricts subsequent raster processing to within the clip area. If there is no subsequent processing, "-clip" will have no effect. See http://www.imagemagick.org/script/comma ... s.php#clip

Next problem: clipping paths that are within an svg file should be processed by the SVG processing, and should already be taken account of when IM rasterises the image.

IM's "-clip" restricts processing to the clipping path in an 8bim profile. For example, abClip.tiff:

https://dl.dropboxusercontent.com/s/4az ... 4S8QQ&dl=1

The raster data in this file is solid green. But it contains a clipping path; use "identify -verbose abClip.tiff".

To use the clipping path, do some processing, eg:

Code: Select all

%IM%convert abclip.tiff -clip -channel R -evaluate set 100% a.png
The result should be a yellow letter "A" on a green background.