简体   繁体   English

batik-rasterizer.jar - 将svg转换为png

[英]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 . 我尝试使用以下命令在我的linux服务器中设置导出服务器,从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. 它在我的本地Windows机器中完美地创建了一个图像,但是我将它上传到我的linux服务器中,我收到了错误。

 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 我注意到图像是用0 kb无效图像创建的

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. 1)包含batik-rasterizer.jar的文件夹,文件以root身份拥有,权限设置为777。

2)i also try to execute it with /user/bin/java , which java insted pf java command. 2)我也尝试用/ user / bin / java执行它, 这是java insted pf java命令。

3)I also try to execute this command as root using terminal using putty,Java is installed in my server. 3)我也尝试使用putty使用终端以root身份执行此命令,Java安装在我的服务器中。

Execute java with the -Djava.awt.headless=true command-line option: 使用-Djava.awt.headless=true命令行选项执行java:

$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. 如果传递附加命令行选项仍未产生预期结果,请检查Java版本。 Updating your JRE to a more recent version (1.7) might also resolve the issue. 将JRE更新为更新版本(1.7)也可能会解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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