svg to png not converting text

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
kruser

svg to png not converting text

Post by kruser »

Hello,

I am attempting to convert a svg file to png. Imagemagick converts the rectangle but not the text. Is my server install no good or ?

svg file:

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="490" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g style="fill:#FFFF00;stroke:#FFFF00;opacity:1;">
<rect x="0" y="0"  width="480" height="100" rx="10" ry="10" />
</g>

<g style="fill:none;stroke:#006400;stroke-width:2;stroke-opacity:1;">
<rect x="6" y="6"  width="468" height="88" rx="10" ry="10"/>
</g>

<g style="font-family:arial;font-size:12;">
<text x="28" y="65" >Hello World</text>
</g>


</svg>
Regards,
Randy
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: svg to png not converting text

Post by magick »

Type
  • convert -list configure
Is Freetype associated with the DELEGATES tag? Its required for proper font rendering. If Freetype is not available, ImageMagick reverts to Postscript fonts which requires the Ghostscript delegate library or program (i.e. gs).

We did try your SVG with ImageMagick 6.4.4-1, the current release, and it rendered properly without complaint.
kruser

Re: svg to png not converting text

Post by kruser »

Magic,

Thanks for the reply. Have been working on this all day. Could not get ImageMagick to convert svg to png with my current host. So I opened a new account with one of the biggest hosting companies to test this on their server. Guess what? It does not convert the svg text. It converts the rectangles but not the text.

Someone please try a convert on your system with the above svg file, then view the new png image to see if the text is in the new image file? If it works with your hosting company, please give me their name.

I would like to check for Freetype but I do not know how to use the command line.

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

Re: svg to png not converting text

Post by anthony »

Look at Rubble Web, which shows how you can run various convert from PHP to find out the build information for the IM "Convert" command you are using.

Without more information it is very difficult to help.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
kruser

Re: svg to png not converting text

Post by kruser »

Anthony,

Thanks for the suggestion to look at the Rubble website as it does contain good information on using PHP to access ImageMagick. One of the pages I found useful was http://www.rubblewebs.biz/imagemagick/b ... xplain.php


Best Regards,
Randy
kruser

Re: svg to png not converting text

Post by kruser »

Was able to use php to view list configure.

results

Code: Select all

# Path: /usr/lib/ImageMagick-6.0.7/config/configure.mgk
#
# Name Value
# -------------------------------------------------------------------------------
# CC gcc
# CFLAGS -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -Wall -pthread
# CONFIGURE ./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --with-perl --with-x --with-threads --with-magick_plus_plus
# COPYRIGHT Copyright (C) 1999-2004 ImageMagick Studio LLC
# CPPFLAGS -I/usr/include
# CVS_BRANCH_TAG HEAD
# CXX g++
# CXXFLAGS -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -pthread
# DISTCHECK_CONFIG_FLAGS --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --with-perl --with-x --with-threads --with-magick_plus_plus'CFLAGS=-O2 -g -pipe -m32 -march=i386 -mtune=pentium4'
# EXEC-PREFIX /usr
# HOST i686-redhat-linux-gnu
# LDFLAGS -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib
# LIB_VERSION 0x607
# LIB_VERSION_NUMBER 6,0,7,1
# LIBS -lMagick -ltiff -lfreetype -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread
# NAME ImageMagick
# PREFIX /usr
# QuantumDepth 16
# RELEASE_DATE 03/07/07
# VERSION 6.0.7
# WEBSITE http://www.imagemagick.org
How do I tell if the Freetype is associated with DELEGATES

Regards,
Randy
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: svg to png not converting text

Post by fmw42 »

what PHP code did you use? your results are missing the line that starts with DELEGATES

put

convert -list configure

into your exec command or whatever you are using. Then you should get a line in the resulting printout that looks something like:

DELEGATES bzlib fontconfig freetype gs jpeg jp2 lcms lqr openexr png tiff x11 xml zlib


If you have installed ghostscript and freetype to IM's satisfaction, then you should see "freetype gs" included in the list
kruser

Re: svg to png not converting text

Post by kruser »

The PHP script I used is

Code: Select all

<html>
<head>
<title>Test for ImageMagick list configure</title>
</head>
<body>

 <?
function alist ($array) { 
  $alist = "<ul>";
  for ($i = 0; $i < sizeof($array); $i++) {
    $alist .= "<li>$array[$i]";
  }
  $alist .= "</ul>";
  return $alist;
}
exec("convert -list configure", $out); 
echo alist($out); 
?>

</body>
</html>
I have no idea why DELEGATES is not there.

Regards,
Randy
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: svg to png not converting text

Post by fmw42 »

Your version is VERSION 6.0.7, which is extremely OLD. Perhaps you should update. The DELEGATES line may have changed since your version. Your version shows:

# LIBS -lMagick -ltiff -lfreetype -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread

Which may now be replaced with Delegates???

I suggest you upgrade to the latest version (6.4.4-1), about 400 minor releases newer.

Seems like you are missing ghostscript from the above list. So you may want to add that along with all the other (upgraded) delegates.
kruser

Re: svg to png not converting text

Post by kruser »

Thanks for the update suggestion. Appreciate it!

Regards,
Randy
Post Reply