im4java を使用して、入力ストリームの画像を出力ストリームに変換しようとしています。FRom ドキュメントでは、inputProvider を入力として設定し、出力ストリームを指定すると、変換された画像をパイプする必要があるように見えますが、次のようになります。
Failed to convert image: more argument images then placeholders
これが私の機能です:
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;
}
ありがとう!