java imagemagick的小问题,返回的状态是4
怪我咯
怪我咯 2017-04-17 17:40:38
0
1
346

最后输入的为什么是4?哪里有问题

String[] cmd = {
                "convert",
                "-scale",
                "98x",
                "-quality",
                "80",
                "C:/opt/trs/data/MD/2016/04/15/W0MD20160415zurj7EINBBE7QiRFrzjU.jpeg",
                "C:/opt/trs/data/MD/2016/04/15/W0MD20160415zurj7EINBBE7QiRFrzjU_98.jpeg" };
        Process proc = Runtime.getRuntime().exec(cmd);// 执行命令
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final InputStream pis = proc.getInputStream();
        final InputStream per = proc.getErrorStream();
        try {
            Thread t = new Thread() {
                public void run() {
                    try {
                        int a = 0;
                        while ((a = per.read()) != -1) {
                            baos.write(a);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            };
            t.start();

            int a = 0;
            while ((a = pis.read()) != -1) {
                baos.write(a);
            }

            t.join();
            int exitCode = proc.waitFor();
            String msg = new String(baos.toByteArray());
            System.out.println("exitCode = "+exitCode);
            System.out.println("msg = "+msg);
        } finally {
            if (pis != null) {
                try {
                    pis.close();
                } catch (Exception ex) {
                }
            }
            if (per != null) {
                try {
                    per.close();
                } catch (Exception ex) {
                }
            }
        }
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回覆(1)
左手右手慢动作

自己的問題從來都只能自己想辦法解決╮(╯▽╰)╭
可能是convert這個命令windows下也有,所以直接改了路徑,改為imagemagick下的convert,問題解決!

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!