xml - Serving SVG as JPEG using Imagick and PHP -


i have svg string want serve jpeg using php. (and lot more things) using imagick. below code php:

$svg = '<?xml version="1.0" encoding="iso-8859-1"?><!doctype svg public "-//w3c//dtd svg 1.1//en" "http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd"><svg version="1.1" id="capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28.125px" height="28.125px" viewbox="0 0 28.125 28.125" style="enable-background:new 0 0 28.125 28.125;" xml:space="preserve" background="transparent"><g><g><path d="m14.063,0l1.659,6.617v0.464c0,13.979,11.906,20.767,12.026,20.834l0.378,0.21l0.377-0.21   c0.12-0.067,12.026-6.854,12.026-20.834v6.617l14.063,0z m14.063,26.329c12.13,25.096,3.445,18.92,3.214,7.544l10.849-5.787 l10.849,5.786c24.681,18.919,15.996,25.094,14.063,26.329z"/><path d="m4.004,8.001c0.416,10.17,7.652,15.812,10.059,17.412c2.407-1.601,9.643-7.241,10.059-17.411l14.063,2.636l4.004,8.001z m14,21.191c-1.067,0-1.778-0.771-1.778-1.799c0-1.047,0.731-1.799,1.778-1.799c1.048,0,1.739,0.752,1.759,1.799 c15.759,20.421,15.067,21.191,14,21.191z m15.127,16.605h-2.253l-0.456-8.954h3.144l15.127,16.605z"/></g></g></svg>'; $image = new imagick(); $image->readimageblob($svg); $image->setimageformat("jpg"); header("content-type: image/jpg"); echo $image; 

the problem here following error when executed:

fatal error: uncaught exception 'imagickexception' message 'no decode delegate image format `' @ error/blob.c/blobtoimage/358' in c:\xampp\htdocs\univar\build\makesprite.php:10 stack trace: #0 c:\xampp\htdocs\univar\build\makesprite.php(10): imagick->readimageblob('<?xml version="...') #1 {main} thrown in c:\xampp\htdocs\univar\build\makesprite.php on line 10 

i clueless happening. tried reading svg file no success. can please help?

i found combination works. after bit of struggle, able below combination work on machine.

os: windows 7 64 bit
php: 5.5.6
xampp: 1.8.3
compiler: msvc11
architecture: x86
imagemagick: imagemagick-6.7.7-5-q16-windows-dll (available here)
imagick dll: php5.5.x version http://www.peewit.fr/imagick/

note: after tried this, apache started without error messages. have imagemagick installed in directory has no spaces in name (as have suggested might problem installs). in case, installed c:\imagemagick.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -