0

パイプを扱う im4java サンプル TestCase10 を試しています。

https://github.com/Widen/im4java/blob/master/src/org/im4java/test/TestCase10.java

 
public class im4Test {

    public static void main(String[] args) throws Exception {
        IMOperation op = new IMOperation();
        op.addImage("-");                   // read from stdin
        op.addImage("tif:-");               // write to stdout in tif-format

        // set up pipe(s): you can use one or two pipe objects
        FileInputStream fis = new FileInputStream("ABC.png");
        FileOutputStream fos = new FileOutputStream("ABC.tif");
        // Pipe pipe = new Pipe(fis,fos);
        Pipe pipeIn  = new Pipe(fis,null);
        Pipe pipeOut = new Pipe(null,fos);

        // set up command
        ConvertCmd convert = new ConvertCmd();
        convert.setInputProvider(pipeIn);
        convert.setOutputConsumer(pipeOut);
        convert.run(op);
        fis.close();
        fos.close();
    }
}

そして例外の下に直面して、何が起こっているのかについての手がかりは大歓迎です。



        Exception in thread "main" org.im4java.core.CommandException: java.io.IOException: The pipe is being closed
        at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
        at com.cvc.image.im4Test.main(im4Test.java:28)
    Caused by: java.io.IOException: The pipe is being closed
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:326)
        at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
        at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
        at org.im4java.process.ProcessStarter.processInput(ProcessStarter.java:261)
        at org.im4java.process.ProcessStarter.waitForProcess(ProcessStarter.java:423)
        at org.im4java.process.ProcessStarter.run(ProcessStarter.java:313)
        at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
        ... 1 more

 

注: Windows で実行し、ImageMagick を使用します。

4

1 に答える 1

0

さらにデバッグすると、問題が見つかりました。他の人の利益のために回答として投稿します。

Windows プラットフォームには独自の「変換」コマンドがあり、干渉しています。

ImageMagick 'convert' コマンドがシステム パスにあり、コマンド ラインでアクセス可能であることを確認し、Eclipse を再起動したにもかかわらず、Eclipse IDE は Windows コマンドを選択しています。

機能させるには、ImageMagick 検索パスを明示的に設定する必要がありました。

ConvertCmd.setSearchPath('imageMagickBinDirPath')
于 2016-11-09T21:34:26.457 に答える