How to configure inkscape to work with Imagemagick?

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
yhuynh
Posts: 17
Joined: 2017-11-20T03:29:58-07:00
Authentication code: 1152

How to configure inkscape to work with Imagemagick?

Post by yhuynh » 2017-11-20T09:52:13-07:00

After installing Inkscape,
I try to make it work with Imagemagick
I notice the delegates.xml file is now like that:

Code: Select all

<delegate decode="svg" command="&quot;rsvg-convert&quot; -o &quot;%o&quot; &quot;%i&quot;"/>
  <delegate decode="svg:decode" stealth="True" command="&quot;inkscape&quot; &quot;%s&quot; --export-eps=&quot;%s&quot; --export-dpi=&quot;%s&quot; --export-background=&quot;%s&quot; --export-background-opacity=&quot;%s&quot; &gt; &quot;%s&quot; 2&gt;&amp;1"/>
 
I notice on thing after installing inkscape : It removed rsvg !
However I decided to continue with inkscape since it works better with svg files.

I have some command like that before installing inkscape :

exec("/usr/bin/convert -background none ".$file." -depth 8 ".$destfile."png 2>&1");

I tried

exec("/usr/bin/convert -background none inkscape:".$file." -depth 8 ".$destfile."png 2>&1"); // $file is svg file

but it says "linked image not found", I do have some links to image, but i don't need, what i need is the base64 image to be converted. Any idea? I can show svg file if you want (3 meg)

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to configure inkscape to work with Imagemagick?

Post by Bonzo » 2017-11-20T11:11:50-07:00

I would guess your original code should work using inkscape instead of rsvg - have you tried? - or use inkscape directly.

yhuynh
Posts: 17
Joined: 2017-11-20T03:29:58-07:00
Authentication code: 1152

Re: How to configure inkscape to work with Imagemagick?

Post by yhuynh » 2017-11-20T11:21:33-07:00

I didn't write this code, so i am not familiar with it, it contains another command : composite

Code: Select all

exec("/usr/bin/composite -compose Dst_In -gravity center ".$masquefolder.$sideMasque." ".$destfolder.$destfile.".png ".$destfolder.$destfile."1.png 2>&1");
exec("/usr/bin/composite -gravity center ".$masquefolder.$sideBordure." ".$destfolder.$destfile."1.png ".$destfolder.$destfile."_final.png 2>&1");
does composite use inkscape also? I will try to make a detailed debugging of the php script to see what is really going on.

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to configure inkscape to work with Imagemagick?

Post by Bonzo » 2017-11-20T11:34:11-07:00

Composite is another of the IMagemagick programs used for combining images. A lot of the composite processes can be done with convert and I belive you can only combine two images with composite but more than 2 using the convert method.

Why not try something simple first without all the variables?

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

Re: How to configure inkscape to work with Imagemagick?

Post by fmw42 » 2017-11-20T11:44:17-07:00

The use of Inkscape or RSVG is only for processing SVG images, not raster images. Composite or convert processes two image of any kind. But it you do not have Inkscape or RSVG then process of SVG files in composite or convert will use the internal MSVG renderer. Composite is independent of Inkscape and RSVG. It simply puts on image over the other. It is limited to two images as is convert ... -compose over -composite. But the latter is more flexible. If you have to combine more than two images you can use -layers flatten or -layers merge.

It is very hard to read code that uses arguments and not actual files. Can you provide an example with actual filenames and provide the images.

It is likely that your two composite lines can be combined into one convert command.

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

Re: How to configure inkscape to work with Imagemagick?

Post by fmw42 » 2017-11-20T13:38:12-07:00

ImageMagick will use Inkscape by default if it is on your system and it can be found. I do not think you need to modify the delegates.xml file to use it, nor to preface the image with Inkscape:yourimage.suffix.

snibgo
Posts: 11994
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to configure inkscape to work with Imagemagick?

Post by snibgo » 2017-11-20T18:41:17-07:00

Prefixing with "inkscape:" is wrong. IM doesn't recognise that prefix. See "convert -list format" for a list of valid prefixes.

After installing Inkscape, you can still use "RSVG:" prefix to SVG files to tell IM to use rsvg. If there is no prefix, IM will use Inkscape.
snibgo's IM pages: im.snibgo.com

yhuynh
Posts: 17
Joined: 2017-11-20T03:29:58-07:00
Authentication code: 1152

Re: How to configure inkscape to work with Imagemagick?

Post by yhuynh » 2017-11-21T00:39:35-07:00

ok I confirm it works without inkscape:.
Let me decipher the PHP program first and i'll get back to you with more sample code.

yhuynh
Posts: 17
Joined: 2017-11-20T03:29:58-07:00
Authentication code: 1152

Re: How to configure inkscape to work with Imagemagick?

Post by yhuynh » 2017-11-21T01:40:36-07:00

The process i like this : I have a svg file as input, and in the svg file there are links to images (same origin), in php.ini allow_url_open = true
this line fails to create the png file, :

Code: Select all

exec("/usr/bin/convert -background none /home/printplusprod/public_html/media/pdp/download/200000497/Item-2477-Mug.svg -depth 8 /home/printplusprod/public_html/media/pdp/download/200000497/Item-2477-Mug.png 2>&1")
I have as a result :
A thumbnail with the text "Linked image not found".

This other line a couple of lines later works :

Code: Select all

exec("/usr/bin/convert -background none /home/printplusprod/public_html/media/pdp/download/200000497/Item-2477-Mug_view.svg -depth 8 -resize 800x800 /home/printplusprod/public_html/media/pdp/download/200000497/Item-2477-Mug_view.png 2>&1")
so why this svg file works? inside, all the links to images are converted to base64 !

Either I have to make convert parse links, or save the svg with all links to images encode in base64.
Any solution with enabling image link opening?

snibgo
Posts: 11994
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to configure inkscape to work with Imagemagick?

Post by snibgo » 2017-11-21T02:03:59-07:00

What version of IM are you using?
yhuynh wrote:... in the svg file there are links to images (same origin), in php.ini allow_url_open = true
this line fails to create the png file, :
First step: isolate the problem. You are using PHP, calling ImageMagick, which does what? Calls Inkscape?

Does Inkscape successfully rasterize the SVG? If not, the SVG has a problem.

Does IM's "convert" work, calling Inkscape? Any error messages? If that works but PHP doesn't, the problem may be permissions.
snibgo's IM pages: im.snibgo.com

yhuynh
Posts: 17
Joined: 2017-11-20T03:29:58-07:00
Authentication code: 1152

Re: How to configure inkscape to work with Imagemagick?

Post by yhuynh » 2017-11-21T02:09:35-07:00

IM version:

Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-07-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


If I do in command line the conversion of Item-2477-Mug.svg with Inkscape:

inkscape Item-2477-Mug.svg --export-png=Item-2477-Mug.png
I get an image with "Linked image not found"

convert work no problem. It's a problem with the SVG file.

Item-2477-Mug.svg is the file with links to image of pattern "http://domain.com/../image.jpg"

Item-2477-Mug_view.svg is the file with all links to images transformed into base64 strings, this one is converted without problem.


I made an experiment, I replace links to image in Item-2477-Mug.svg by the absolute path like "/home/printplusprod/public_html/media...", inkscape can do the conversion, as well as convert.

snibgo
Posts: 11994
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to configure inkscape to work with Imagemagick?

Post by snibgo » 2017-11-21T02:29:20-07:00

So, is your problem solved?
snibgo's IM pages: im.snibgo.com

yhuynh
Posts: 17
Joined: 2017-11-20T03:29:58-07:00
Authentication code: 1152

Re: How to configure inkscape to work with Imagemagick?

Post by yhuynh » 2017-11-21T03:17:54-07:00

I opted for the replace "http://" by absolute path and it works like a charm. thanks. Problem solved !

Post Reply