Error in exporting raphaeljs to jpg with path background as image Error in exporting raphaeljs to jpg with path background as image php php

Error in exporting raphaeljs to jpg with path background as image


If you're able to get correct output to svg but it fails going to png in php there are several things you'll need to check.

  • As a sanity check make sure your $_POST['json'] is not returning malformed json
  • The next line in your php confuses me: $output = str_replace('\"','"',$json);
  • It could be that the json you're returning is a single object, but I'm still not sure why you are searching the entire file and not looking for a specific nested object like $output = str_replace('\"','"',$json['filename_and_path']); and if the json you return IS a single line, there may be better ways to handle it -- i.e. post it as a string or even return each one with an array and index.

And for this stuff:

$konwert = "convert $filenameSVG.svg $filenameSVG.jpg";system($konwert);

You may not be feeding system() with valid variables in your string. To be sure I recommend properly concatenating the string like:

$konwert = "convert".$filenameSVG.".svg ".$filenameSVG.".jpg";

You're also going to need the absolute filepath to the file on your server to execute the command on or else it won't find the file. The code $konwert = "convert".$filenameSVG.".svg ".$filenameSVG.".jpg"; is obviously only going to work for you if those two files are located in the root directory of your project.

I also don't think you should be using system() in this instance. My understanding is you should be using passthru() for dealing with image binaries. There's also exec() but really, I think what you need here is passthru(). See: http://www.php.net/manual/en/function.passthru.php


It looks like your path is just setting up a container for the image. Couldn't you use:

paper.image('images/alfen/02/murek.png', 50, 50, 300, 195);

It seems like it may be more reliable. You could use that as your starter and add whetever paths you like to it. I've had problems using an image as a fill because they never seem to render where I expect them to.

And you can still use: paper.toSVG()

I was able to get that version to convert without any trouble.