码迷,mamicode.com
首页 > 其他好文 > 详细

使用svgo压缩图片

时间:2020-03-03 10:47:11      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:red   input   run   home   div   node   ejs   throws   svg   

要先安装nodejs和svgo 

安装好nodejs后在cmd里面输入npm i svgo -g(liunx下直接输入)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by Administrator on 2020/3/2.
 */
public class TestTT {

    public static void main(String[] args) throws IOException, InterruptedException {
        String command = "cmd /c svgo d:/dwg/a.svg"; //windows
//        String command = " svgo /home/a.svg";//linux
//        String command = "ping baidu.com -t";
//        String command = "cmd /c node -v";
        Process process = Runtime.getRuntime().exec(command);
        BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        process.waitFor();
        System.out.println ("exit: " + process.exitValue());
        process.destroy();
    }
}

  

使用svgo压缩图片

标签:red   input   run   home   div   node   ejs   throws   svg   

原文地址:https://www.cnblogs.com/james-roger/p/12400855.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!