Page 1 of 1

Misplaced rasterized SVG elements

Posted: 2011-08-15T13:18:45-07:00
by razor7
Hi, iḿ using this little chunk of code to convert from SVG to JPG using IMagick API.

The code works flawlessly, but the rasterized JPG got some elements misplaces (I tthink that the rotated ones only)

This is the code

Code: Select all

<?php



$usmap = '/www/docs/.com.ar/public_html/presugen/export/svgGenerado.svg';

$im = new Imagick();

$svgin = file_get_contents($usmap);



$im->readImageBlob($svgin);



/*jpeg settings*/

$im->setImageFormat("jpeg");



$im->writeImage('/www/docs/.com.ar/public_html/presugen/export/svgRasterizado.jpg');/*(or .jpg)*/



$im->clear();

$im->destroy();



?>
I have attached the SVG file, that loads OK in InkScape
svgGenerado.svg.tar.bz2
(37.04 KiB) Downloaded 1305 times
and this is the rasterized image
svgRasterizado.jpg
svgRasterizado.jpg (29.69 KiB) Viewed 19963 times
Also tested with commandline "convert" but same result.

Please advise, is the last think to finish my project.

Thans a lot!

Re: Misplaced rasterized SVG elements

Posted: 2011-08-15T16:49:52-07:00
by magick
You may be using the internal SVG renderer which is not as good as the librsvg delegate library. We're using ImageMagick 6.7.1-5 and get correct results. This command:
  • identify -list format
returns
  • SVG SVG rw+ Scalable Vector Graphics (RSVG 2.32.1)
which shows SVG images are rendered with the librsvg delegate library.

Re: Misplaced rasterized SVG elements

Posted: 2011-08-15T17:39:47-07:00
by razor7
OK, what i have to ask to my share hosting provider? Do the need to install something?

Thanks a lot!

Re: Misplaced rasterized SVG elements

Posted: 2011-08-15T18:28:05-07:00
by magick
Sure, you need to install librsvg2 and librsvg2-devel then rebuild / reinstall ImageMagick.

Re: Misplaced rasterized SVG elements

Posted: 2011-08-16T08:15:14-07:00
by razor7
Well, I tryed it on my ubuntu PC issuing theese commands
$ sudo apt-get remove imagemagick
$ sudo apt-get install imagemagick librsvg2-bin
But when i run $ identify -list format i still get
...
SVG SVG rw+ Scalable Vector Graphics (XML 2.7.6)
...

Re: Misplaced rasterized SVG elements

Posted: 2011-08-16T09:35:28-07:00
by magick
The ImageMagick RPM is already built without RSVG support. You need to download and build ImageMagick from source. Install ImageMagick-devel and then download ftp://ftp.imagemagick.org/pub/ImageMagi ... 1-6.tar.gz. Now type
  • tar xvfz ImageMagick-6.7.1-6.tar.gz
    cd ImageMagick-6.7.1-6
    ./configure
    make
    make install

Re: Misplaced rasterized SVG elements

Posted: 2011-08-16T09:39:47-07:00
by razor7
So firt thing to do is install librsvg2 and librsvg2-devel, then uninstall current imagemagick and then download, compile and install im, thats right?

Re: Misplaced rasterized SVG elements

Posted: 2011-08-16T10:47:51-07:00
by magick
Sounds about right. Have fun.