convert SVG to PNG (textPath)

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
ph7

convert SVG to PNG (textPath)

Post by ph7 »

Hello,

im trying to convert a svg file to png under Linux (Debian)
Almost every thing works fine.
I only have a problem with the tag "textPath".
After convert from svg to png the text is not printed along the path. (see below)

Is this a problem which will be fixed in the future? (I'm runing 6.2.4.5)

Code: Select all

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000px" height="707px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
	<path id="MyPath" d="M 599,455 A 244,244 0 0,1 723,578" />
</defs>
<use xlink:href="#MyPath" fill="none" stroke="red"  />
<text font-family="Verdana" font-size="42.5" fill="blue" >
<textPath xlink:href="#MyPath">
 We go up, then we go down, then up again
</textPath>
</text>
</svg>
http://creatiese.com/test.svg
http://creatiese.com/test.png


Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert SVG to PNG (textPath)

Post by anthony »

textPath is not implemented in the built-in SVG converter of IM. However if available IM will use the libRSVG library to do SVG conversion, and this does get it right.

Also a perl module has been release to externally implement text path using Perl-Magick
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ph7

Re: convert SVG to PNG (textPath)

Post by ph7 »

I built a package (configure, make, make install) with the same result.
Below I a list with the settings. What else could be wrong?
Any idea?

Thanks

Code: Select all

Host system type : i686-pc-linux-gnu

                  Option                        Value
-------------------------------------------------------------------------------
Shared libraries  --enable-shared=yes           yes
Static libraries  --enable-static=yes           yes
Module support    --with-modules=yes            yes
GNU ld            --with-gnu-ld=yes             yes
Quantum depth     --with-quantum-depth=16       16
High Dynamic Range Imagery
                  --enable-hdri=no              no

Delegate Configuration:
BZLIB             --with-bzlib=yes              yes
DJVU              --with-djvu=no                no
DPS               --with-dps=yes                no
FlashPIX          --with-fpx=yes                no
FontConfig        --with-fontconfig=yes         yes
FreeType          --with-freetype=yes           yes
GhostPCL          None                          pcl6 (unknown)
Ghostscript       None                          gs (8.54)
result_ghostscript_font_dir='none'
Ghostscript fonts --with-gs-font-dir=default
Ghostscript lib   --with-gslib=yes              no
Graphviz          --with-gvc=yes                no
JBIG              --with-jbig=yes               no
JPEG v1           --with-jpeg=yes               yes
JPEG-2000         --with-jp2=yes                yes
LCMS              --with-lcms=yes               yes
Magick++          --with-magick-plus-plus=yes   no (failed tests)
OpenEXR           --with-openexr=yes            no
PERL              --with-perl=yes               /usr/bin/perl
PNG               --with-png=yes                yes
RSVG              --with-rsvg=yes               yes
TIFF              --with-tiff=yes               yes
result_windows_font_dir='none'
Windows fonts     --with-windows-font-dir=
WMF               --with-wmf=yes                yes
X11               --with-x=                     yes
XML               --with-xml=yes                yes
ZLIB              --with-zlib=yes               yes

X11 Configuration:
      X_CFLAGS        =
      X_PRE_LIBS      = -lSM -lICE
      X_LIBS          =
      X_EXTRA_LIBS    =

Options used to compile and link:
  PREFIX          = /usr/local
  EXEC-PREFIX     = /usr/local
  VERSION         = 6.3.7
  CC              = gcc
  CFLAGS          = -g -O2 -Wall -W -pthread
  MAGICK_CFLAGS   = -g -O2 -Wall -W -pthread
  CPPFLAGS        = -I/usr/local/include
  PCFLAGS         =
  DEFS            = -DHAVE_CONFIG_H
  LDFLAGS         = -lfreetype -lz
MAGICK_LDFLAGS  = -L/usr/local/lib -lfreetype -lz
  LIBS            = -lMagick -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lpthread
  CXX             = gpp
  CXXFLAGS        = -pthread
tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: convert SVG to PNG (textPath)

Post by tsdineen »

Try the latest 6.3.8 version. There was a small change to the svg lib, that may help your cause.
ph7

Re: convert SVG to PNG (textPath)

Post by ph7 »

Thanks for the advise. I tried today 6.3.8 version but with almost the same result
http://creatiese.com/test.svg
http://creatiese.com/test.png
It seems that the bugfix (Set RSVG base URI (patch provided by tsdineen).) helped a bit.
Can it be, that imagemagick has a problem to match "textPath" and "path" by id?

Thanks
tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: convert SVG to PNG (textPath)

Post by tsdineen »

What happens when you use rsvg directly?

rsvg test.svg test.png

It's possible that there is some missing initialization code in the svg.so that may be in th rsvg main code.
ph7

Re: convert SVG to PNG (textPath)

Post by ph7 »

Thanks for the tip.
There were no runtime script under the "librsvg2-dev" debian package.
So I installed librsvg-2.20.0 from source and got the same result ('rsvg test.svg test.png' =>no Text around the graph) with no warnings.
It seems that the problem comes with the rsvg package and not with ImageMagick.

At the end I tried to convert svg to png with inkscape and it works.

Has someone successful convert svg (with textPath) to png under ImageMagick? I'm not quit sure if that is generell problem or just a wrong configuration of my server.

For the moment I have a solution (inkscape), but I still like to find the real cause.

Thanks
tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: convert SVG to PNG (textPath)

Post by tsdineen »

I've not tried the converion you mentioned, but I am also using a different version of rsvg. I believe I am using the last verison before they started using Cario, which is 2.12.7.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert SVG to PNG (textPath)

Post by anthony »

ph7 wrote:There were no runtime script under the "librsvg2-dev" debian package.
The run time programs are often installed using a different package to the library itself. Under fedora they are part of the library package but that may not be the case under debian.

Fedora package included the programs, rsvg, rsvg-convert, rsvg-view, along with the library.

My version of IM also did not convert the text in the SVG provided. But then neither did RSVG, which is not suprising, considering that my IM uses the same library.

The RSVG is a full SVG implementation and I have see it do text paths, so I say something is wrong with the SVG, even though my firefox offical Adobe implementation displays it as expected.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply