Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 pngcrush 来优化我的 png 图像。我可以使用以下命令在终端上运行它
$ pngcrush -brute -e "Optimize.png" filename.png
但我想从我的 Java 程序中实现它。我怎样才能实现它?我用谷歌搜索了它,但没有找到任何相关信息。
您可以直接从程序中调用命令:
public class Main { public static void main(String[] args) { try { String[] command = {"pngcrush", "-brute, "-e", "Optimize.png", "filename.png"}; Runtime.getRuntime().exec(command); } catch (java.io.IOException e) { e.printStackTrace(); } } }