0
im4java를 사용하여 입력 스트림의 이미지를 출력 스트림으로 변환하려고합니다. 워드 프로세서, 그것은 입력으로 inputProvider을 설정하고 출력 스트림해야 파이프 변환 된 이미지를 지정처럼 보이는,하지만 난 얻을 :ImageMagick : 파이프 된 이미지 변환
public static InputStream convert(InputStream imageStream){
try {
// Set up the im4java properties. See {@link im4java}
IMOperation op = new IMOperation();
op.scale(1000);
op.compress("Zip");
ConvertCmd convert = new ConvertCmd();
convert.setSearchPath(imLocation);
logger.debug("Imagemagick located at: " + convert.getSearchPath());
InputStream is = imageStream;
ByteArrayOutputStream os = new ByteArrayOutputStream();
Pipe pipeIn = new Pipe (is, null);
Pipe pipeOut = new Pipe(null, os);
convert.setInputProvider(pipeIn);
convert.setOutputConsumer(pipeOut);
convert.run(op, "-", "pdf:-");
is.close();
os.close();
pipeOut.consumeOutput(is);
return is;
}catch(Exception e){
logger.debug("Failed to convert image: " + e.getMessage());
}
return null;
}
감사 :
Failed to convert image: more argument images then placeholders
가 여기 내 기능입니다!
하지 질문에 대한 대답,하지만 당신은 당신이'is'을 폐쇄하고 그 후'pipeOut.consumeOutput (이다)를 호출 주목 한,'당신은 폐쇄'is'을 반환한다. 그 확인은? 나는 잘 모르겠다. –