0
나는 파이프를 다루는 im4java 샘플 인 TestCase10을 시험 중이다.im4java로 파이프 변환
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();
}
}
https://github.com/Widen/im4java/blob/master/src/org/im4java/test/TestCase10.java
그리고 예외 아래에 직면하고는, 무슨 일이 일어나고 있는지에 대한 단서가 대단히 감사합니다.
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을 사용 중입니다.
몇 가지 사항을 확인해야합니다. 입력 이미지가 있어야하는 위치는 어디입니까? 그리고이 과정에서 읽을 수 있습니까? 출력 디렉토리가이 프로세스에서 쓰기 가능합니까? 'addImage ("-")'를'addImage ("png : -")'로 변경할 수 있습니까? 입력 및 출력 이미지를 GIF 또는 JPEG로 변경하면 작동합니까? –