本文整理汇总了Java中org.im4java.core.ConvertCmd.setOutputConsumer方法的典型用法代码示例。如果您正苦于以下问题:Java ConvertCmd.setOutputConsumer方法的具体用法?Java ConvertCmd.setOutputConsumer怎么用?Java ConvertCmd.setOutputConsumer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.im4java.core.ConvertCmd
的用法示例。
在下文中一共展示了ConvertCmd.setOutputConsumer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertWithOptions
import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
public byte[] convertWithOptions(InputStream image, String options) {
String[] optionStrings = options.split(" ");
IMOperation iMOperation = new IMOperation();
iMOperation.addImage("-");
iMOperation.addRawArgs(optionStrings);
iMOperation.addImage(":-");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Pipe pipeIn = new Pipe(image, null);
Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
ConvertCmd convertCmd = new ConvertCmd();
convertCmd.setInputProvider(pipeIn);
convertCmd.setOutputConsumer(pipeOut);
try {
convertCmd.run(iMOperation);
} catch (IOException | InterruptedException | IM4JavaException exception) {
System.err.println(exception.getMessage());
}
return byteArrayOutputStream.toByteArray();
}
示例2: convert2ImageFormat
import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
public static byte[] convert2ImageFormat(InputStream image, String format) throws IOException, InterruptedException, IM4JavaException {
IMOperation iMOperation = new IMOperation();
iMOperation.addImage("-");
iMOperation.addImage( format + ":-");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Pipe pipeIn = new Pipe(image, null);
Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
ConvertCmd convertCmd = new ConvertCmd();
convertCmd.setInputProvider(pipeIn);
convertCmd.setOutputConsumer(pipeOut);
convertCmd.run(iMOperation);
return byteArrayOutputStream.toByteArray();
}
示例3: resize
import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
protected static byte[] resize(InputStream image, Integer maxWidth, Integer maxHeight, String format, boolean keepAspectRatio) throws IOException, InterruptedException, IM4JavaException {
IMOperation iMOperation = new IMOperation();
iMOperation.addImage("-");
if(!keepAspectRatio) {
iMOperation.resize(maxWidth, maxHeight, '!');
} else {
iMOperation.resize(maxWidth, maxHeight);
}
iMOperation.addImage(format + ":-");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Pipe pipeIn = new Pipe(image, null);
Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
ConvertCmd convertCmd = new ConvertCmd();
convertCmd.setInputProvider(pipeIn);
convertCmd.setOutputConsumer(pipeOut);
convertCmd.run(iMOperation);
return byteArrayOutputStream.toByteArray();
}
示例4: crop
import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
static byte[] crop(InputStream image, int width, int height, int offsetX, int offsetY, String format, int rwidth, int rheight) throws IOException, InterruptedException, IM4JavaException {
IMOperation iMOperation = new IMOperation();
iMOperation.addImage("-");
iMOperation.crop(width, height, offsetX, offsetY);
iMOperation.repage(rwidth, rheight);
iMOperation.addImage(format + ":-");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Pipe pipeIn = new Pipe(image, null);
Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
ConvertCmd convertCmd = new ConvertCmd();
convertCmd.setInputProvider(pipeIn);
convertCmd.setOutputConsumer(pipeOut);
convertCmd.run(iMOperation);
return byteArrayOutputStream.toByteArray();
}
示例5: rotate
import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
static byte[] rotate(InputStream image, double degrees, String format) throws IOException, InterruptedException, IM4JavaException {
IMOperation iMOperation = new IMOperation();
iMOperation.addImage("-");
iMOperation.rotate(degrees);
iMOperation.addImage(format + ":-");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Pipe pipeIn = new Pipe(image, null);
Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
ConvertCmd convertCmd = new ConvertCmd();
convertCmd.setInputProvider(pipeIn);
convertCmd.setOutputConsumer(pipeOut);
convertCmd.run(iMOperation);
return byteArrayOutputStream.toByteArray();
}