Conversion of SVG image to PNG will text adds backslashes before quotation marks
Conversion of SVG image to PNG will text adds backslashes before quotation marks
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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.
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.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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.
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.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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
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?
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?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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.
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.
That problem goes away if we remove all those (superfluous?) white rectangles from the SVG.hairykid wrote:This works, however it is now cutting off the right edge of my images. Hmmm, any ideas?
snibgo's IM pages: im.snibgo.com
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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
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
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
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
The patch is in the current releases of ImageMagick, 7.0.8-34 and 6.9.10-35. No Beta required.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Conversion of SVG image to PNG will text adds backslashes before quotation marks
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
When running sudo apt upgrade imagemagick I get the following -
imagemagick is already the newest version (8:6.9.10.8+dfsg-1ubuntu2)
imagemagick is already the newest version (8:6.9.10.8+dfsg-1ubuntu2)