I'm currently working on some tools to allow web-based creation of various types of maps for people that aren't comfortable editing SVG files. These tools will allow users to select a base map, choose which territories they want to shade in and how to shade them, generate an SVG file, and then push it to Commons. I have pretty much everything working except I would like to be able to show the user a PNG preview of their map before it is pushed to Commons. I tried using ImageMagick, but it gives horrible results. Has anyone else dealt with this problem on the toolserver? I've heard of a couple other possible solutions: 1. SVG2image, which is a PHP class that uses the Batik Java library to do the conversion. Apparently this is difficult to set-up, however, and may not work under PHP 5. 2. The librsvg library. Apparently this library may have some security problems, however, and reports of its ability to do decent conversions are mixed. 3. Calling inkscape from the command line. I doubt this is available on the toolserver, but who knows.
Any ideas would be appreciated. Thanks.
Ryan Kaldari
On Mon, Feb 15, 2010 at 6:53 PM, Ryan Kaldari kaldari@gmail.com wrote:
I'm currently working on some tools to allow web-based creation of various types of maps for people that aren't comfortable editing SVG files. These tools will allow users to select a base map, choose which territories they want to shade in and how to shade them, generate an SVG file, and then push it to Commons. I have pretty much everything working except I would like to be able to show the user a PNG preview of their map before it is pushed to Commons. I tried using ImageMagick, but it gives horrible results. Has anyone else dealt with this problem on the toolserver?
Wikimedia uses rsvg, so that would be your best choice -- that way your PNG has a fairly good chance of actually looking the same as Wikimedia's rasterization. rsvg is installed on nightshade, and since it's installed on willow and wolfsbane I assume it's installed on all the Solaris servers as well.
Hi,
Am 16.02.2010, 00:53 Uhr, schrieb Ryan Kaldari kaldari@gmail.com:
Has anyone else dealt with this problem on the toolserver? I've heard of a couple other possible solutions:
I'm using rsvg on the toolserver for four years now and it produces good results. You could simply run it "rsvg source.svg dest.png". I don't know about security problems, but as I understood, you create the SVGs for your own, so this shouldn't be a problem.
Sincerelly, Christian Thiele / apper
Thanks for the tip. I'll try that.
Ryan Kaldari
On Mon, Feb 15, 2010 at 6:21 PM, Christian Thiele apper@apper.de wrote:
Hi,
Am 16.02.2010, 00:53 Uhr, schrieb Ryan Kaldari kaldari@gmail.com:
Has anyone else dealt with this problem on the toolserver? I've heard of a couple other possible solutions:
I'm using rsvg on the toolserver for four years now and it produces good results. You could simply run it "rsvg source.svg dest.png". I don't know about security problems, but as I understood, you create the SVGs for your own, so this shouldn't be a problem.
Sincerelly, Christian Thiele / apper
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
Christian Thiele:
I don't know about security problems, but as I understood, you create the SVGs for your own, so this shouldn't be a problem.
The security problem with rsvg, at least when called from the command line, is that it will honour any external file references in the SVG file. If you generate the SVG yourself, this doesn't apply, because you control any such references.
The rsvg version on the Solaris systems (but *not* on Linux) has Wikimedia's patch to disable external file inclusion, so it should be safe to process untrusted SVGs with that.
- river.
For some reason I can't get the command to work properly from PHP, although it works fine from the command line. I tried to execute the following from PHP on nightshade: $command = "rsvg newmap.svg newmap.png"; $makemap = system($command, $retval); if ($retval) echo "PNG creation error."; This creates a file called newmap.png, but the file is always 0 bytes, and no error is returned. Running the same command from the command line works perfectly. Any idea what's wrong? Could this have anything to do with the rsvg security patch? Do I need to pass the file differently within a script?
Ryan Kaldari
On Mon, Feb 15, 2010 at 6:21 PM, Christian Thiele apper@apper.de wrote:
Hi,
Am 16.02.2010, 00:53 Uhr, schrieb Ryan Kaldari kaldari@gmail.com:
Has anyone else dealt with this problem on the toolserver? I've heard of a couple other possible solutions:
I'm using rsvg on the toolserver for four years now and it produces good results. You could simply run it "rsvg source.svg dest.png". I don't know about security problems, but as I understood, you create the SVGs for your own, so this shouldn't be a problem.
Sincerelly, Christian Thiele / apper
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
Hi,
Am 17.02.2010, 00:46 Uhr, schrieb Ryan Kaldari kaldari@gmail.com:
it works fine from the command line. I tried to execute the following from
if it works from command line, try shell_exec() instead of system().
Sincerelly, Christian Thiele
I tried shell_exec() and exec() instead of system() and it gives the same resullt - a zero byte file with no error. Any idea why it would work from the command line but not from PHP?
Ryan Kaldari
On Wed, Feb 17, 2010 at 12:09 AM, Christian Thiele apper@apper.de wrote:
Hi,
Am 17.02.2010, 00:46 Uhr, schrieb Ryan Kaldari kaldari@gmail.com:
it works fine from the command line. I tried to execute the following from
if it works from command line, try shell_exec() instead of system().
Sincerelly, Christian Thiele
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
Дана Wednesday 17 February 2010 17:49:26 Ryan Kaldari написа:
I tried shell_exec() and exec() instead of system() and it gives the same resullt - a zero byte file with no error. Any idea why it would work from the command line but not from PHP?
Could you try running any other command (say, 'ls') and see if there is output? Could you try running rsvg with 2>&1 and see if there is output?
Good idea. The output from rsvg with 2>&1 is "Error reading SVG:". I've tried using the full path to the SVG and even setting the permissions on the file to 777, but I still get the same error. I also tried putting the command in a shell script and executing the shell script from PHP, but it gives the same results: a zero byte PNG file.
Is PHP running within some kind of sandbox or do I need to change an ini setting perhaps to let it read files off the server. Sorry for all the newbie questions.
Ryan Kaldari
On Wed, Feb 17, 2010 at 12:02 PM, Nikola Smolenski smolensk@eunet.rswrote:
Дана Wednesday 17 February 2010 17:49:26 Ryan Kaldari написа:
I tried shell_exec() and exec() instead of system() and it gives the same resullt - a zero byte file with no error. Any idea why it would work from the command line but not from PHP?
Could you try running any other command (say, 'ls') and see if there is output? Could you try running rsvg with 2>&1 and see if there is output?
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
Дана Wednesday 17 February 2010 20:55:28 Ryan Kaldari написа:
Good idea. The output from rsvg with 2>&1 is "Error reading SVG:". I've tried using the full path to the SVG and even setting the permissions on the file to 777, but I still get the same error. I also tried putting the command in a shell script and executing the shell script from PHP, but it gives the same results: a zero byte PNG file.
To me, it seems it can't find the SVG file. Try replacing rsvg with echo to see what exactly are you giving it; then try replacing it with cat to see if anything could find the file.
shell_exec("cat newmap.svg 2>&1"); outputs the svg file to the browser, so it can definitely find the file. I'm stumped. What's the difference between running rsvg directly from the command line and executing it from PHP? Perhaps there are some environment restrictions or something. Has anyone else been able to successfully execute rsvg from PHP on nightshade?
Ryan Kaldari
On Wed, Feb 17, 2010 at 3:28 PM, Nikola Smolenski smolensk@eunet.rs wrote:
Дана Wednesday 17 February 2010 20:55:28 Ryan Kaldari написа:
Good idea. The output from rsvg with 2>&1 is "Error reading SVG:". I've tried using the full path to the SVG and even setting the permissions on the file to 777, but I still get the same error. I also tried putting the command in a shell script and executing the shell script from PHP, but it gives the same results: a zero byte PNG file.
To me, it seems it can't find the SVG file. Try replacing rsvg with echo to see what exactly are you giving it; then try replacing it with cat to see if anything could find the file.
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
Am 17.02.2010 22:36, schrieb Ryan Kaldari:
shell_exec("cat newmap.svg 2>&1");
With my tests only rsvg on nightshade can read the test-svg [1], here it works with and without php (called from the shell). The same calls on willow (with and without php, via shell) results in a message of "Error reading SVG:", the same thing happens on wolfsbane (php via webserver). So I guess the solaris versions of rsvg may have some problem..
What's the difference between running rsvg directly from the command line and executing it from PHP?
executing it from PHP is not the problem, but the login-server is not the same machine as the webserver.
Peter
[1] http://toolserver.org/~mazder/mapnik-in-a-box/svgicons/mazdermind/grave_yard.svg
Ryan Kaldari wrote:
shell_exec("cat newmap.svg 2>&1"); outputs the svg file to the browser, so it can definitely find the file. I'm stumped. What's the difference between running rsvg directly from the command line and executing it from PHP? Perhaps there are some environment restrictions or something. Has anyone else been able to successfully execute rsvg from PHP on nightshade?
First, even if you wouldn't have these problems, you really should be using full paths to files. So, please, /usr/bin/rsvg-convert /tmp/whatever/newmap.svg
Second, try "strace -e file -f rsvg newmap.svg 2>&1" and if you don't see anything useful, the same without "-e file". You should see what exactly fails in the last lines.
Nikola Smolenski schrieb:
Ryan Kaldari wrote:
shell_exec("cat newmap.svg 2>&1"); outputs the svg file to the browser, so it can definitely find the file. I'm stumped. What's the difference between running rsvg directly from the command line and executing it from PHP? Perhaps there are some environment restrictions or something. Has anyone else been able to successfully execute rsvg from PHP on nightshade?
First, even if you wouldn't have these problems, you really should be using full paths to files. So, please, /usr/bin/rsvg-convert /tmp/whatever/newmap.svg
On nightshade rsvg is "/usr/bin/rsvg", on willow and wolfsbane it's "/opt/ts/bin/rsvg" so to be cross-server compatible we need to use "rsvg" and rely on the PATH-Environment Variable.
Second, try "strace -e file -f rsvg newmap.svg 2>&1" and if you don't see anything useful, the same without "-e file". You should see what exactly fails in the last lines.
I'm not able to execute strace on willow or via http on wolfsbane: ERROR: unable to open /dev/log
http://toolserver.org/~mazder/rsvg.php http://toolserver.org/~mazder/rsvg.phps
Peter
Peter Körner:
I'm not able to execute strace on willow or via http on wolfsbane:
The equivalent of the Linux "strace" utility on Solaris is "truss". Solaris "strace" is something completely unrelated.
- river.
Ryan Kaldari kaldari@gmail.com wrote:
I tried shell_exec() and exec() instead of system() and it gives the same resullt - a zero byte file with no error. Any idea why it would work from the command line but not from PHP?
Are you sure there is no error? STDERR is usually discarded by shell_exec () and similar functions. Try redirecting it to STDOUT with "rsvg some thing 2>&1".
Tim
Please see the follow-up email. Thanks for the help!
On Wed, Feb 17, 2010 at 2:14 PM, Tim Landscheidt tim@tim-landscheidt.dewrote:
Ryan Kaldari kaldari@gmail.com wrote:
I tried shell_exec() and exec() instead of system() and it gives the same resullt - a zero byte file with no error. Any idea why it would work from the command line but not from PHP?
Are you sure there is no error? STDERR is usually discarded by shell_exec () and similar functions. Try redirecting it to STDOUT with "rsvg some thing 2>&1".
Tim
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
toolserver-l@lists.wikimedia.org