batik-rasterizer.jar - 将svg转换为png [英] batik-rasterizer.jar - convert svg to png
问题描述
我尝试在我的linux服务器中使用以下命令设置导出服务器,以便从 Highcharts 。
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";
它在我的本地Windows机器中完美地创建了一个图像,但我将它上传到我的linux服务器中,我我收到错误。
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?
我注意到图像是使用0 kb无效图像创建的
And i notice that an image is created with 0 kb invalid image
注意: 我也尝试了以下方法。
1)包含蜡染的文件夹-rasterizer.jar和文件的所有者为root,权限设置为777。
1)folder containing batik-rasterizer.jar and the files have owner as root and permission is set as 777.
2)我也尝试用 / user / bin /执行它java ,哪个java insted pf java 命令。
2)i also try to execute it with /user/bin/java , which java insted pf java command.
3)我也尝试执行此操作使用putty使用终端以root身份命令,Java安装在我的服务器中r。
3)I also try to execute this command as root using terminal using putty,Java is installed in my server.
推荐答案
使用执行java -Djava.awt.headless = true
命令行选项:
$command = "java -Djava.awt.headless=true -jar batik-rasterizer.jar -m image/png -d temp/out.png temp/in.svg 2>&1 ";
更新
如果传递附加命令行选项仍未产生预期结果,请检查Java版本。将JRE更新为更新版本(1.7)也可能会解决问题。
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.
这篇关于batik-rasterizer.jar - 将svg转换为png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!