Ampersand symbol in text fails to convert svg to png
Ampersand symbol in text fails to convert svg to png
I have this issue that I have been struggling with and can't seem to resolve. Specifically, I am converting an svg image to png. This works beautifully. However, if the svg image contains ampersand symbol in its text, then the generated png file ends up being empty. The font for the text can be of any kind.
My typical convert command is:
"convert": "-background transparent -size 525x510 svg:- -units PixelsPerInch -density 300 -depth 8 -alpha off -fill #FFFFFE -opaque #FFFFFF -alpha on -bordercolor #FFFFFF -border 0 png:-"
The sample svg input file is https://s3-us-west-1.amazonaws.com/topg ... e25533.svg.
I am currently on CentOS release 6.4 (Final) running ImageMagick 6.8.7-1 2013-10-20 Q16
and my delegate is
$ convert -list configure | grep DELEGATES
DELEGATES bzlib djvu mpeg fontconfig freetype jng jpeg lcms openexr pango png ps tiff x xml zlib
Any help on this will be very much appreciated.
My typical convert command is:
"convert": "-background transparent -size 525x510 svg:- -units PixelsPerInch -density 300 -depth 8 -alpha off -fill #FFFFFE -opaque #FFFFFF -alpha on -bordercolor #FFFFFF -border 0 png:-"
The sample svg input file is https://s3-us-west-1.amazonaws.com/topg ... e25533.svg.
I am currently on CentOS release 6.4 (Final) running ImageMagick 6.8.7-1 2013-10-20 Q16
and my delegate is
$ convert -list configure | grep DELEGATES
DELEGATES bzlib djvu mpeg fontconfig freetype jng jpeg lcms openexr pango png ps tiff x xml zlib
Any help on this will be very much appreciated.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Ampersand symbol in text fails to convert svg to png
SVG follows the usual XML character definitions, so "&" (no quotes) should work.
snibgo's IM pages: im.snibgo.com
Re: Ampersand symbol in text fails to convert svg to png
Not sure I understand. In the svg files, the text is represented already as "Patrick & Kathleen". Hence imagemagick so convert it to png without a problem, right?
Re: Ampersand symbol in text fails to convert svg to png
Any thoughts from anyone else on this issue? I also noticed that some other special characters like double quotes get converted to a single quote. Did anyone ever experience this?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Ampersand symbol in text fails to convert svg to png
What version of IM are you using? What is the SVG renderer?
For me, IM 6.8.9-5, with Inkscape v0.48, the following SVG renders fine:
If this doesn't work for you, I suggest you try it with Inkscape as the delegate.
For me, IM 6.8.9-5, with Inkscape v0.48, the following SVG renders fine:
Code: Select all
<svg height="100%"
version="1.1"
width="100%"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 700 200"
preserveAspectRatio="xMinYMin"
style="overflow: hidden; position: relative;">
<text x="350.00"
y="100.00"
text-anchor="middle"
stroke="none"
fill="#000000"
font-size="40px"
style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-size: 40px; line-height: normal;">
<tspan dy="17"
style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Bill & Ben single ' double "</tspan>
</text>
</svg>
Code: Select all
convert text3.svg billandben.png
If this doesn't work for you, I suggest you try it with Inkscape as the delegate.
snibgo's IM pages: im.snibgo.com
Re: Ampersand symbol in text fails to convert svg to png
Thank you for testing further.
I am running 6.8.7-1 2013-10-20 Q16. My config uses the following delegate:
[tango@centos]$ convert -list delegate | grep 'svg ='
svg => "rsvg-convert" -o "%o" "%i"
Your created image shows as broken. When I take your svg sample, it converts with ampersand in it but it has two problems:
1. The space between Ben and ampersand gets lost.
2. Double quote gets ignored.
Here is the converted png so you can see for yourself - https://s3-us-west-1.amazonaws.com/topg ... simple.png
I am running 6.8.7-1 2013-10-20 Q16. My config uses the following delegate:
[tango@centos]$ convert -list delegate | grep 'svg ='
svg => "rsvg-convert" -o "%o" "%i"
Your created image shows as broken. When I take your svg sample, it converts with ampersand in it but it has two problems:
1. The space between Ben and ampersand gets lost.
2. Double quote gets ignored.
Here is the converted png so you can see for yourself - https://s3-us-west-1.amazonaws.com/topg ... simple.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Ampersand symbol in text fails to convert svg to png
This command works fine for me on IM 6.8.9.8 Q16 Mac OSX using
convert -list format
...
SVG SVG rw+ Scalable Vector Graphics (RSVG 2.40.2)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.40.2)
...
The only issue is that snibgo's svg file (I named it test.svg) has no font specified. So I get my systems default font or SVG default font? I do not know how you get the font you are showing in your example.
Perhaps you just need to upgrade RSVG. See the command I used above to find out what version I am using.
convert -list format
...
SVG SVG rw+ Scalable Vector Graphics (RSVG 2.40.2)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.40.2)
...
Code: Select all
convert -background transparent -size 525x510 test.svg -units PixelsPerInch -density 300 -depth 8 \
-alpha off -fill "#FFFFFE" -opaque "#FFFFFF" -alpha on -bordercolor "#FFFFFF" -border 0 test.png
The only issue is that snibgo's svg file (I named it test.svg) has no font specified. So I get my systems default font or SVG default font? I do not know how you get the font you are showing in your example.
Perhaps you just need to upgrade RSVG. See the command I used above to find out what version I am using.
Re: Ampersand symbol in text fails to convert svg to png
Hello fmw42,
Thank you for your thoughts. My CentOS runs
[tango@centos ~]$ convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (XML 2.7.6)
SVGZ rw+ Compressed Scalable Vector Graphics (XML 2.7.6)
If test.svg does not have the font specified, why is my generating using scripted font? Either way, why does the text omit spacing and double quotes? I am at loss what is going on.
Thank you for your thoughts. My CentOS runs
[tango@centos ~]$ convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (XML 2.7.6)
SVGZ rw+ Compressed Scalable Vector Graphics (XML 2.7.6)
If test.svg does not have the font specified, why is my generating using scripted font? Either way, why does the text omit spacing and double quotes? I am at loss what is going on.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Ampersand symbol in text fails to convert svg to png
I suggest you try an explicit font, eg insert a line after the fill:
Make sure the font is one you actually have, and isn't some freebie home-made font that might have missing glyphs etc.
Code: Select all
fill="#000000"
font-family="Verdana"
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: Ampersand symbol in text fails to convert svg to png
These are all IM internal MSVG. You would do better using RSVG or Inkscape. The IM internal MSVG is the least accurate of the 3.MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (XML 2.7.6)
SVGZ rw+ Compressed Scalable Vector Graphics (XML 2.7.6)
Re: Ampersand symbol in text fails to convert svg to png
Thanks for suggestion that delegates may be the culprit.
I have spent entire weekend to try to validate that this is indeed the delegates. Namely, I did the following:
1. Span up brand new CentOS 6.5 VM.
2. As root, Installed the latest ImageMagick from source as follows:
wget http://www.imagemagick.org/download/Ima ... 9-8.tar.gz
tar xvzf ImageMagick-6.8.9-8.tar.gz
cd ImageMagick-6.8.9-8
yum install gcc
yum install make
yum install ghostscript
sudo yum install librsvg2 librsvg2-devel libpng-devel bzip2-devel djvulibre-devel freetype-devel libjpeg-devel ghostscript-devel libtiff-devel libX11-devel pango-devel libxml2-devel lcms-devel OpenEXR-devel
/configure --enable-delegate-build --enable-shared --with-rsvg=yes
make
make install
3. Here is the outcome
% convert --version
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-13 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib cairo djvu fontconfig freetype jng jpeg lcms openexr pangocairo png rsvg tiff x xml zlib
% convert -list configure | grep DELEGATES
DELEGATES bzlib djvu mpeg fontconfig freetype jng jpeg lcms openexr pango png ps rsvg tiff x xml zlib
convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (RSVG 2.26.0)
SVGZ rw+ Compressed Scalable Vector Graphics (RSVG 2.26.0)
But trying to convert the same simple svg sample file that was posted by you guys produces errors:
convert test.svg test.png
convert: no decode delegate for this image format `test.svg' @ error/svg.c/ReadSVGImage/2954.
convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3187
I am at complete loss here as to what is going on. I think the community would benefit a great deal if someone took the time to provide exact details on how to control delegates installations, including upgrading them (if the above is old version, how do I upgrade it? Given that I installed the latest version of ImageMagick from source, what is the required/supported rsvg library, how do I upgrade it??). There is ton of raised issues revolving around delegates. Most of them end up in concluding that person does not have delegates environment setup right but I get the feeling that most people abandon ImageMagick as it become a black hole. I would take time to document this myself but I am in as much need for answers on delegate installation as everyone else. Please help.
I have spent entire weekend to try to validate that this is indeed the delegates. Namely, I did the following:
1. Span up brand new CentOS 6.5 VM.
2. As root, Installed the latest ImageMagick from source as follows:
wget http://www.imagemagick.org/download/Ima ... 9-8.tar.gz
tar xvzf ImageMagick-6.8.9-8.tar.gz
cd ImageMagick-6.8.9-8
yum install gcc
yum install make
yum install ghostscript
sudo yum install librsvg2 librsvg2-devel libpng-devel bzip2-devel djvulibre-devel freetype-devel libjpeg-devel ghostscript-devel libtiff-devel libX11-devel pango-devel libxml2-devel lcms-devel OpenEXR-devel
/configure --enable-delegate-build --enable-shared --with-rsvg=yes
make
make install
3. Here is the outcome
% convert --version
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-13 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib cairo djvu fontconfig freetype jng jpeg lcms openexr pangocairo png rsvg tiff x xml zlib
% convert -list configure | grep DELEGATES
DELEGATES bzlib djvu mpeg fontconfig freetype jng jpeg lcms openexr pango png ps rsvg tiff x xml zlib
convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (RSVG 2.26.0)
SVGZ rw+ Compressed Scalable Vector Graphics (RSVG 2.26.0)
But trying to convert the same simple svg sample file that was posted by you guys produces errors:
convert test.svg test.png
convert: no decode delegate for this image format `test.svg' @ error/svg.c/ReadSVGImage/2954.
convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3187
I am at complete loss here as to what is going on. I think the community would benefit a great deal if someone took the time to provide exact details on how to control delegates installations, including upgrading them (if the above is old version, how do I upgrade it? Given that I installed the latest version of ImageMagick from source, what is the required/supported rsvg library, how do I upgrade it??). There is ton of raised issues revolving around delegates. Most of them end up in concluding that person does not have delegates environment setup right but I get the feeling that most people abandon ImageMagick as it become a black hole. I would take time to document this myself but I am in as much need for answers on delegate installation as everyone else. Please help.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Ampersand symbol in text fails to convert svg to png
It sure looks like everything went fine. IM can find the RSVG delegate. But it does not seem to be working. Perhaps there was an error on install or it needs some subordinate delegate. Check the install logs to see that there was no errors installing RSVG.
Also check your delegates.xml file to see if it has entries for SVG, such as
<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 am not sure I can help further. I am on a Mac and use MacPorts to install my delegates.
Perhaps one of the Linux users can offer further insight.
Also check your delegates.xml file to see if it has entries for SVG, such as
<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 am not sure I can help further. I am on a Mac and use MacPorts to install my delegates.
Perhaps one of the Linux users can offer further insight.
Re: Ampersand symbol in text fails to convert svg to png
Thanks fmw42,
Let me review delegates.xml. Where can I find the errors logged to see if there is any RSVG install problems reported?
Any linux experts out there who could help here, please?
Let me review delegates.xml. Where can I find the errors logged to see if there is any RSVG install problems reported?
Any linux experts out there who could help here, please?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Ampersand symbol in text fails to convert svg to png
When you install RSVG, there should be a config.log file in the download folder for RSVG. Or look in the IM folder for config.log and see if any errors there.rs13 wrote:Thanks fmw42,
Let me review delegates.xml. Where can I find the errors logged to see if there is any RSVG install problems reported?
Re: Ampersand symbol in text fails to convert svg to png
Here is the config.log after I installed imagemagick as per the earlier thread: https://s3-us-west-1.amazonaws.com/topg ... config.log.
Can you please take a look and see if you can spot any issues? I do not see any errors in that file but perhaps you will be able to tell if the rsvg settings are incorrect.
Thank you!
Can you please take a look and see if you can spot any issues? I do not see any errors in that file but perhaps you will be able to tell if the rsvg settings are incorrect.
Thank you!