当前位置: 首页>>代码示例>>Java>>正文


Java IMOperation.format方法代码示例

本文整理汇总了Java中org.im4java.core.IMOperation.format方法的典型用法代码示例。如果您正苦于以下问题:Java IMOperation.format方法的具体用法?Java IMOperation.format怎么用?Java IMOperation.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.im4java.core.IMOperation的用法示例。


在下文中一共展示了IMOperation.format方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImageInfo

import org.im4java.core.IMOperation; //导入方法依赖的package包/类
/**
 * 获取图片信息
 * 
 * @param srcImagePath 图片路径
 * @return Map {height=, filelength=, directory=, width=, filename=}
 */
public static Map<String, Object> getImageInfo(String srcImagePath) {
    IMOperation op = new IMOperation();
    op.format("%w,%h,%d,%f,%b");
    op.addImage(srcImagePath);
    IdentifyCmd identifyCmd = (IdentifyCmd) getImageCommand(CommandType.identify);
    ArrayListOutputConsumer output = new ArrayListOutputConsumer();
    identifyCmd.setOutputConsumer(output);
    try {
        identifyCmd.run(op);
    } catch (Exception e) {
        e.printStackTrace();
    }
    ArrayList<String> cmdOutput = output.getOutput();
    if (cmdOutput.size() != 1)
        return null;
    String line = cmdOutput.get(0);
    String[] arr = line.split(",");
    Map<String, Object> info = new HashMap<String, Object>();
    info.put("width", Integer.parseInt(arr[0]));
    info.put("height", Integer.parseInt(arr[1]));
    info.put("directory", arr[2]);
    info.put("filename", arr[3]);
    info.put("filelength", Integer.parseInt(arr[4]));
    return info;
}
 
开发者ID:hailin0,项目名称:im4java-util,代码行数:32,代码来源:ImageUtil.java

示例2: run_returnsResultBack

import org.im4java.core.IMOperation; //导入方法依赖的package包/类
@Test
public void run_returnsResultBack() throws Exception {
    final String command = "identify";
    sut = new GMBatchCommand(service, command);
    IMOperation op = new IMOperation();
    op.ping();
    final String format = "%m\n%W\n%H\n%g\n%z";
    op.format(format);
    op.addImage();
    ArrayListOutputConsumer output = new ArrayListOutputConsumer();
    sut.setOutputConsumer(output);
    when(service.execute(anyListOf(String.class))).thenReturn("JPEG\n800\n600\n800x600\n0\n");

    sut.run(op, SOURCE_IMAGE);

    verify(service).execute(Arrays.asList(command, "-ping", "-format", format, SOURCE_IMAGE));
    // ... and parse result
    ArrayList<String> cmdOutput = output.getOutput();
    Iterator<String> iter = cmdOutput.iterator();
    assertThat(iter.next(), is("JPEG"));
    assertThat(iter.next(), is("800"));
    assertThat(iter.next(), is("600"));
    assertThat(iter.next(), is("800x600"));
    assertThat(iter.next(), is("0"));
}
 
开发者ID:sharneng,项目名称:gm4java,代码行数:26,代码来源:GMBatchCommandTest.java

示例3: fillPNGOptions

import org.im4java.core.IMOperation; //导入方法依赖的package包/类
private static void fillPNGOptions(IMOperation op) {
	op.define("png:color-type=6");
	op.set("png:color-type", "6");
	op.set("png:interlace-method", "0");
	op.set("png:bit-depth", "8");
	op.colorspace("sRGB");
	op.compress("None");
	op.transparentColor("None");
	op.interlace("None");
	op.format("png");
	op.depth(8);
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:13,代码来源:ImgMagickUtils.java

示例4: getImageInfo

import org.im4java.core.IMOperation; //导入方法依赖的package包/类
/**
 * 获取图片基本信息
 * 
 * @param is
 * @return
 * @throws IOException
 * @throws InterruptedException
 * @throws IM4JavaException
 *
 */
public static List<Integer> getImageInfo(InputStream is) throws IOException, InterruptedException, IM4JavaException {
	
	List<Integer> imagewh = new ArrayList<Integer>();

	IMOperation op = new IMOperation();

	op.format("%w,%h");// ,path:%d%f,size:%b%[EXIF:DateTimeOriginal]

	op.addImage(1);

	IdentifyCmd cmd = new IdentifyCmd(GraphicImageConstants.GM);

	ArrayListOutputConsumer output = new ArrayListOutputConsumer();

	BufferedImage img = ImageIO.read(is);

	cmd.setOutputConsumer(output);

	cmd.run(op, img);

	ArrayList<String> cmdOutput = output.getOutput();

	String[] line = cmdOutput.get(0).split(",");

	Integer width = Integer.valueOf(line[0]);

	Integer height = Integer.valueOf(line[1]);

	imagewh.add(width);

	imagewh.add(height);

	return imagewh;

}
 
开发者ID:lklong,项目名称:imageweb,代码行数:46,代码来源:ImageUtil.java


注:本文中的org.im4java.core.IMOperation.format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。