When I convert eps to svg in the terminal using inkscape, it works fine. But when I execute the same command using php's shell_exec, it doesn't work. (I also tried exec and system with no luck)
Sample code:
<?php
unlink('./sample.svg');
$file_path = realpath('./sample.eps');
$dest_path = getcwd() . '/sample.svg';
//# inkscape --file=sample.eps --export-plain-svg=sample.svg
// command works fine in terminal but not in php
$command = "inkscape --file=$file_path --export-plain-svg=$dest_path";
// command fails with no output (null)
$output = shell_exec($command);
var_dump($output);
var_dump(is_file('./sample.svg'));
The same command also works correctly from php shell! I couldn't determine the cause because I couldn't check the output (it's always null)
Conversion worked fine with ai -> svg and pdf -> svg
I have not replied to your message, because it's over my head. But I wanted to say thanks for your research and thanks for sharing the solultion you found. I'm sure others will find it helpful.
Hello,
When I convert eps to svg in the terminal using inkscape, it works fine.
But when I execute the same command using php's shell_exec, it doesn't work. (I also tried exec and system with no luck)
Sample code:
The same command also works correctly from php shell!
I couldn't determine the cause because I couldn't check the output (it's always null)
Conversion worked fine with ai -> svg and pdf -> svg
I suspect that this is a similar issue to command works fine through terminal but not shell_exec php but what would be the solution to this case?
PS: I'm using this sample eps file for testing
Any help is much appreciated, Thank you
Here's the output I got from php
I found the solution
http://www.inkscapeforum.com/viewtopic.php?t=19303
Welcome to the forum!
I have not replied to your message, because it's over my head. But I wanted to say thanks for your research and thanks for sharing the solultion you found. I'm sure others will find it helpful.
Thank you,
In fact, a simpler solution would be to add PATH=/usr/bin to the command like so
Cheers
Good to know! I haven't played with Inkscape CLI in a long while but it can be super useful :)