Page 1 of 1
converting svg to png generates blank file
Posted: 2013-10-18T10:54:58-07:00
by rs13
Hello,
I have been pulling my hair for several days on this and hoping someone can help me.
I am converting svg to png and getting a blank file generated. I am running CentOS 6.4 and I believe I am using the rsvg library and rsvg is setup as a delegate as shown below
$ convert -list format | grep SVG
MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (RSVG 2.26.0)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.26.0)
$ convert -list configure | grep DELEGATES
DELEGATES bzlib djvu fontconfig freetype gslib jng jp2 jpeg lcms openexr pango png ps rsvg tiff wmf x xml zlib
$ convert -list delegate | grep 'svg ='
svg => "rsvg-convert" -o "%o" "%i"
I do not get any error when running the convert command. The crazy thing that on my test server where I run Fedora, the svg to png works and when I look at the settings there I get similar output with exception that the type for Scalable Vector Graphics says '(XML 2.7.8 )'
convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (XML 2.7.8 )
SVGZ rw+ Compressed Scalable Vector Graphics (XML 2.7.8 )
Is my issue stemming from the fact that I run old RSVG 2.26.0? What does 'XML' denote.
Note that I even build from source: ImageMagick-6.8.7-0.src.rpm and it still just installed rvsg 2.26.0.
Thank you in advance for your help.
Re: converting svg go png generates blank file
Posted: 2013-10-18T11:04:58-07:00
by snibgo
Can you put up the SVG file? If it is fairly small, paste the contents here between [ code ] and [ /code ]. If it is large, put it somewhere like dropbox and paste the URL here.
Re: converting svg to png generates blank file
Posted: 2013-10-18T12:28:56-07:00
by rs13
I am attaching the sample svg file below. When I run it using
$ convert -size 400x400 test.svg friday2.png
the resulting png file is not empty. See
https://www.dropbox.com/s/lvyv1ls4yq82tc0/friday2.png.
Code: Select all
<svg id="abc" xmlns="http://www.w3.org/2000/svg" version="1.2" xmlns:xlink="http://www.w3.org/1999/xlink" ng-style="{width:(s.dim.w*zoom)+'px',height:(s.dim.h*zoom)+'px'}" ng-controller="surface" style="width: 600px; height: 600px;">
<g transform="translate(300,300)">
<defs>
<clipPath id="id0.30758465453982353">
<path sa="d=M-205,0 a205,205 0 1,0 410,00 a205,205 0 1,0 -410,00" transform="scale(1.4634146341463414,1.4634146341463414)" d="M-205,0 a205,205 0 1,0 410,00 a205,205 0 1,0 -410,00"></path>
</clipPath>
<linearGradient id="vertical" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:;stop-opacity:1"></stop>
<stop offset="100%" style="stop-color:;stop-opacity:1"></stop>
</linearGradient>
<linearGradient id="horizontal" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:;stop-opacity:1"></stop>
<stop offset="100%" style="stop-color:;stop-opacity:1"></stop>
</linearGradient>
<radialGradient id="radial" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:;stop-opacity:1"></stop>
<stop offset="100%" style="stop-color:;stop-opacity:1"></stop>
</radialGradient>
</defs>
<path sa="d=M-205,0 a205,205 0 1,0 410,00 a205,205 0 1,0 -410,00;fill=url(#)" ng-show="s.$design.background.color.style=='gradient'&&s.$design.background.value=='Colors'&&s.$design.background.color.type&&s.$design.background.color.from&&s.$design.background.color.to" transform="scale(1.4634146341463414)" d="M-205,0 a205,205 0 1,0 410,00 a205,205 0 1,0 -410,00" fill="url(#)" style="display: none;"></path>
<path sa="d=M-205,0 a205,205 0 1,0 410,00 a205,205 0 1,0 -410,00;fill=#f33838" ng-show="s.$design.background.color.style=='solid'&&s.$design.background.value=='Colors'&&s.$design.background.color.color" transform="scale(1.4634146341463414,1.4634146341463414)" d="M-205,0 a205,205 0 1,0 410,00 a205,205 0 1,0 -410,00" fill="#0000ff" style="display: none;"></path>
<g clip-path="url(#id0.30758465453982353)">
<g ng-switch="" on="s.$design.background.value">
<!-- ngSwitchWhen: Theme -->
<!-- ngSwitchWhen: Texture -->
</g>
<!-- ngRepeat: a in s.$design.layers --><g ng-repeat="a in s.$design.layers" ng-switch="" on="a.type">
<!-- ngSwitchWhen: picture -->
<!-- ngSwitchWhen: text --><text ng-switch-when="text" ng-mouseover="select($index,false)" ng-click="select($index,true);changeOrder($event,true)" sa="id=text0;x=-304.75198684571114;y=-67.03754453274868;dy=.91em;fill=#ff0000;font-size=104.93833927103314" style="font-weight:default;font-style:normal;text-decoration:default;font-family:helvetica;" id="text0" x="-304.75198684571114" y="-67.03754453274868" dy="80px" fill="#ff0000" font-size="104px">BLABLABLA</text>
</g><g ng-repeat="a in s.$design.layers" ng-switch="" on="a.type">
<!-- ngSwitchWhen: picture --><image ng-switch-when="picture" xlink:href="http://s3-us-west-1.amazonaws.com/topgun.tango/sites/myjb/artworks/MrJB/MrJB_Birthday_Cake2.png" sa="x=-240;y=-240;width=480;height=480;xlink:href=http://s3-us-west-1.amazonaws.com/topgun.tango/sites/myjb/artworks/MrJB/MrJB_Birthday_Cake2.png" preserveAspectRatio="none" ng-mouseover="select($index,false)" ng-click="select($index,true);changeOrder($event,true)" x="-240" y="-240" width="480" height="480"></image>
<!-- ngSwitchWhen: text -->
</g>
</g>
</g>
</svg>
Re: converting svg to png generates blank file
Posted: 2013-10-19T14:23:08-07:00
by rs13
Snibgo or anyone else, can you guys help?
Re: converting svg to png generates blank file
Posted: 2013-10-20T01:21:41-07:00
by rich2005
A couple of thoughts, although this was done on an old-ish linux netbook (Bodhi 1) and IM 6.6.2 so a bit different from CentOS
The svg contains a linked image rather than an embedded image - the url that ends.
'..MrJB_Birthday_Cake2.png'
For some purpose I can not figure out, there is a circular clipping path over the grouped objects.
Can not see the linked object being picked up and the clipping path possibly hides the rest.
A bit of editing on the svg file and a local '...cake2.png', got this
http://i.imgur.com/7nC8BUM.jpg
Re: converting svg to png generates blank file
Posted: 2013-10-20T03:34:31-07:00
by snibgo
Your friday2.png is entirely white.
On Windows 7, IM v6.8.7-0, when I run ...
Code: Select all
convert -size 400x400 friday2.svg f.png
... I get a warning about unable to read fonts, and a cartoon image captioned "BLABLAB", on a blue quarter-circle.
Do simpler SVG files convert properly?
Re: converting svg to png generates blank file
Posted: 2013-10-20T08:59:03-07:00
by rs13
Hello,
The test.svg file that I provided is just an example. The main issue is that no svg file, no matter how simple converts to png.
Re: converting svg to png generates blank file
Posted: 2013-10-20T09:31:25-07:00
by snibgo
Ah, okay. If your IM can't convert SVG at all, then something is wrong with either the configuration or (more likely, I think) the build.
As I know nothing about building nor CentOS, sorry, I can't help.
Re: converting svg to png generates blank file
Posted: 2013-10-20T22:03:56-07:00
by rs13
I burned lot of midnight oil to figure this out and hopefully it will save someone time. Basically on CentOS to get the more recent version of ImageMagick I found it nearly impossible to do so unless you compile from source. This is because there is simply too many dependencies and CentOS being very conservative in its Repos, you get one dependency exception after another.
Hence here goes the steps to compile from source:
wget
http://www.imagemagick.org/download/Ima ... 7-1.tar.gz
tar xvzf ImageMagick-6.8.7-1.tar.gz
cd ImageMagick-6.8.7-1
yum install gcc
yum install make
yum install ghostscript
yum install 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
make
make install
convert --version
vi test.svg
convert -size 400x400 test.svg friday2.png
Note that installing all the packages before running 'configure' includes the delegate library which then subsequently get incorporated during the ImageMagick's make. You do not need all of the packages, only those that make sense to your use case. Lastly, in order to convert svg to png, it turns out I only need libxml2-devel and purposely excluded libsrvg-devel which when installed resulting in the final png file to be blank - this is still very bizzare for me as I thought rsvg delegate library is ultimately what you want. After the above, my installed delegates look as follows:
convert -list configure | grep DELEGATES
DELEGATES bzlib djvu mpeg fontconfig freetype jng jpeg lcms openexr pango png ps tiff x xml zlib