I have a problem with raphaeljs export plugin ( https://github.com/ElbertF/Raphael.Export ).
in a path element I use attribute fill
and as a source I give a image url to fullfill. But when I export this to SVG I see a path element definition, but when I export it to PNG, I do not see again.
So in my app I add an attr
to path
element like this:
paper.path("M 195 10 L 300 L 195 z").attr({'stroke-width': 0,'fill': 'url(images/alfen/02/murek.png)'});
and I export this with paper.toSVG()
and in my SVG I find a path:
<path transform="matrix(1,0,0,1,0,0)" fill="url(images/alfen/02/murek.png)" stroke="#000" d="M203,183.94389438943895L948,183.94389438943895L948,195L203,195Z" stroke-width="0"></path>
But when I transform this to PNG with:
<?php
$json = $_POST['json'];
$output = str_replace('\"','"',$json);
$filenameSVG = 'test';
file_put_contents("$filenameSVG.svg", $output);
$konwert = "convert $filenameSVG.svg $filenameSVG.jpg";
system($konwert);
I cannot find this path fulfilled with my background. Can anybody help?
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.
$output = str_replace('\"','"',$json);
$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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With