Page 1 of 1
Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-12T08:33:47-07:00
by hairykid
Hi,
My website deals with print and the user can design their print before previewing their design - at which point the svg image which is generated with JS in real time is converted using imagemagick into a png.
The issue is that if you add the text for example - Hi my name's Gary.
It will convert to png as - Hi my name\'s Gary.
I can't find anything online mentioning this, only people talking about text conversion through command line.
Hoping someone can help me with this please.
Thanks v much
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-12T08:51:13-07:00
by snibgo
We need a reproducible example. Please post a sample SVG.
Please also say what version of IM you use, on what platform. Also: what delegate does your IM use to rasterize the SVG? This might be MSVG, RSVG or Inkscape.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-12T08:52:40-07:00
by fmw42
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-12T09:20:30-07:00
by hairykid
Hi thanks for both of your quick replies and sorry for not reading the post first I didn't see this, but I accept I should have checked first.
Running the command "convert -version" outputs -
Version: ImageMagick 6.9.10-8 Q16 x86_64 20180723
I am using Ubuntu 18.10
The command being run is -
convert +antialias msvg:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-950397970-7EUq2J png:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-573026719-dP1ZEa
The svg image is here -
https://ufile.io/b8cgr
The converted png is here -
https://ufile.io/6sayx
Thanks again
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-12T10:00:14-07:00
by snibgo
I don't know why IM using MSVG inserts a backslash before the quote. I suppose that is a bug.
As a workaround, remove the "MSVG:" prefix. Then IM will use RSVG (provided IM has been built with RSVG). The result seems good to me.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-12T13:55:44-07:00
by fmw42
Or install Inkscape which is generally better than RSVG and does not need to have ImageMagick recompiled with RSVG. ImageMagick will use inkscape by default if it finds it on your system.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-13T04:55:03-07:00
by hairykid
Thanks for your replies, appreciated.
I've tried installing inkscape, can I still use the same command? -
convert +antialias msvg:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-950397970-7EUq2J png:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-573026719-dP1ZEa
As this is not working, not sure if it is using Inkscape, is there anyway to tell?
I have tried without MSVG: -
convert +antialias /var/www/mydomain.co.uk/sites/default/files/tmp/preview-950397970-7EUq2J png:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-573026719-dP1ZEa
This works, however it is now cutting off the right edge of my images. Hmmm, any ideas?
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-13T06:05:36-07:00
by snibgo
If you have a MSVG: prefix, this forces IM to use MSVG, so it won't use Inkscape.
If you have no prefix, it will use Inkscape if it can, otherwise RSVG if it can, otherwise MSVG.
In general, Inkscape is the most powerful (it implements more SVG, and does so correctly) but is also slowest.
hairykid wrote:This works, however it is now cutting off the right edge of my images. Hmmm, any ideas?
That problem goes away if we remove all those (superfluous?) white rectangles from the SVG.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-14T06:30:47-07:00
by hairykid
Thanks, I am going to test this again soon and will report back.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-14T08:14:37-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @
https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @
http://www.imagemagick.org/download/beta/ by sometime tomorrow.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-15T05:32:15-07:00
by hairykid
Awesome news! Great that I was of some help to find this bug.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-16T06:03:33-07:00
by hairykid
Out of interest, is it possible to install the beta version through command line in Linux Ubuntu?
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-16T11:18:19-07:00
by magick
The patch is in the current releases of ImageMagick, 7.0.8-34 and 6.9.10-35. No Beta required.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-16T11:37:51-07:00
by fmw42
Did you not mean 6.9.10-34 and not 6.9.10.35? I see no 6.9.10.35 in the install from source list.
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Posted: 2019-03-18T02:29:09-07:00
by hairykid
When running sudo apt upgrade imagemagick I get the following -
imagemagick is already the newest version (8:6.9.10.8+dfsg-1ubuntu2)