ホームページ  >  に質問  >  本文

java imagemagick的小问题,返回的状态是4

最后输入的为什么是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) {
                }
            }
        }
怪我咯怪我咯2712日前352

全員に返信(1)返信します

  • ringa_lee

    ringa_lee2017-04-17 17:42:38

    私自身の問題はいつも自分で解決してきました╮(╯▽╰)╭
    たぶんconvertコマンドはWindowsでも利用できるので、imagemagickの下でconvertするパスを直接変更したら問題は解決しました!

    返事
    0
  • キャンセル返事