简体   繁体   中英

batik-rasterizer.jar - convert svg to png

I was try yo setup an export server in my linux server with the following command to download graph as image from Highcharts .

$command = "java -jar batik-rasterizer.jar -m image/png -d temp/1a6b5dd08ec607454b81f91097fb24a6.png temp/1a6b5dd08ec607454b81f91097fb24a6.svg 2>&1 "; 
$output = shell_exec($command);
echo "Command: $command <br>";
echo "Output: $output";

It creates an image in my local windows machine perfectly ,But i uploaded it in my linux server,I am getting errors.

 About to transcode 1 SVG file(s) Converting 1a6b5dd08ec607454b81f91097fb24a6.svg to temp/1a6b5dd08ec607454b81f91097fb24a6.png ... (.:21519): Gtk-WARNING **: cannot open display:

Why this happens?

And i notice that an image is created with 0 kb invalid image

Note: I have also tried the following methods .

1)folder containing batik-rasterizer.jar and the files have owner as root and permission is set as 777.

2)i also try to execute it with /user/bin/java , which java insted pf java command.

3)I also try to execute this command as root using terminal using putty,Java is installed in my server.

Execute java with the -Djava.awt.headless=true command-line option:

$command = "java -Djava.awt.headless=true -jar batik-rasterizer.jar -m image/png -d temp/out.png temp/in.svg 2>&1 "; 

Update

If passing the additional command-line option still does not yield the expected result, check your Java version. Updating your JRE to a more recent version (1.7) might also resolve the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM