Misplaced rasterized SVG elements

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
User avatar
razor7
Posts: 4
Joined: 2011-08-15T13:08:29-07:00
Authentication code: 8675308

Misplaced rasterized SVG elements

Post 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 1304 times
and this is the rasterized image
svgRasterizado.jpg
svgRasterizado.jpg (29.69 KiB) Viewed 19956 times
Also tested with commandline "convert" but same result.

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

Thans a lot!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Misplaced rasterized SVG elements

Post 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.
User avatar
razor7
Posts: 4
Joined: 2011-08-15T13:08:29-07:00
Authentication code: 8675308

Re: Misplaced rasterized SVG elements

Post by razor7 »

OK, what i have to ask to my share hosting provider? Do the need to install something?

Thanks a lot!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Misplaced rasterized SVG elements

Post by magick »

Sure, you need to install librsvg2 and librsvg2-devel then rebuild / reinstall ImageMagick.
User avatar
razor7
Posts: 4
Joined: 2011-08-15T13:08:29-07:00
Authentication code: 8675308

Re: Misplaced rasterized SVG elements

Post 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)
...
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Misplaced rasterized SVG elements

Post 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
User avatar
razor7
Posts: 4
Joined: 2011-08-15T13:08:29-07:00
Authentication code: 8675308

Re: Misplaced rasterized SVG elements

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Misplaced rasterized SVG elements

Post by magick »

Sounds about right. Have fun.
Post Reply