Page 1 of 1
How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T09:52:13-07:00
by yhuynh
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=""rsvg-convert" -o "%o" "%i""/>
<delegate decode="svg:decode" stealth="True" command=""inkscape" "%s" --export-eps="%s" --export-dpi="%s" --export-background="%s" --export-background-opacity="%s" > "%s" 2>&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)
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T11:11:50-07:00
by Bonzo
I would guess your original code should work using inkscape instead of rsvg - have you tried? - or use inkscape directly.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T11:21:33-07:00
by yhuynh
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T11:34:11-07:00
by Bonzo
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?
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T11:44:17-07:00
by fmw42
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T13:38:12-07:00
by fmw42
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-20T18:41:17-07:00
by snibgo
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-21T00:39:35-07:00
by yhuynh
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-21T01:40:36-07:00
by yhuynh
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?
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-21T02:03:59-07:00
by snibgo
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-21T02:09:35-07:00
by yhuynh
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.
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-21T02:29:20-07:00
by snibgo
So, is your problem solved?
Re: How to configure inkscape to work with Imagemagick?
Posted: 2017-11-21T03:17:54-07:00
by yhuynh
I opted for the replace "http://" by absolute path and it works like a charm. thanks. Problem solved !