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


Java IM4JavaException类代码示例

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


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

示例1: test_2

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
@Test
public void test_2() throws IOException, InterruptedException, IM4JavaException {

	ConvertCmd cvcmd = new ConvertCmd(GM);

	Operation op = new Operation();
	op.addImage(PIC_PATH);
	op.addRawArgs("-sample", "600x600^");
	op.addRawArgs("-gravity", "center");
	op.addRawArgs("-extent", "600x600");
	op.addRawArgs("-quality", "100");
	op.addImage(NEW_PIC_PATH);

	cvcmd.run(op);

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

示例2: convertWithOptions

import org.im4java.core.IM4JavaException; //导入依赖的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();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:26,代码来源:ConvertFunction.java

示例3: convert2ImageFormat

import org.im4java.core.IM4JavaException; //导入依赖的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();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:18,代码来源:Convert.java

示例4: resize

import org.im4java.core.IM4JavaException; //导入依赖的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();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:24,代码来源:Convert.java

示例5: crop

import org.im4java.core.IM4JavaException; //导入依赖的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();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:22,代码来源:Convert.java

示例6: rotate

import org.im4java.core.IM4JavaException; //导入依赖的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();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:19,代码来源:Convert.java

示例7: scaleImageByWidth

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
/**
 * 根据最大宽度图片压缩
 *
 * @param ori     原图位置
 * @param dest    目标位置
 * @param maxSize 指定压缩后最大边长
 * @return boolean
 * @throws IOException
 */
public static boolean scaleImageByWidth(String ori, String dest, int maxSize) throws IOException, IM4JavaException, InterruptedException {
    String imageProcessor = appContext.getConfig().get("image_processor");
    if (imageProcessor != null && "Thumbnailator".equals(imageProcessor)) {
        ImageUtils.scaleImageByWidth(ori, dest, maxSize);
    }else {
        GMagickUtils.scaleImageByWidth(ori, dest, maxSize);
    }
    return true;
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:19,代码来源:ImageHandleUtils.java

示例8: scale

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
public static void scale(String ori, String dest, int width, int height) throws IOException, IM4JavaException, InterruptedException {
    String imageProcessor = appContext.getConfig().get("image_processor");
    if (imageProcessor != null && "Thumbnailator".equals(imageProcessor)) {
        ImageUtils.scale(ori, dest, width, height);
    } else{
        GMagickUtils.scale(ori, dest, width,height);
    }
    Thumbnails.of(ori).size(width, height).toFile(dest);
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:10,代码来源:ImageHandleUtils.java

示例9: scaleImage

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
/**
 * 图片压缩,各个边按比例压缩
 *
 * @param ori     原图位置
 * @param dest    目标位置
 * @param maxSize 指定压缩后最大边长
 * @return boolean
 * @throws IOException
 */
public static boolean scaleImage(String ori, String dest, int maxSize) throws IOException, IM4JavaException, InterruptedException {
    String imageProcessor = appContext.getConfig().get("image_processor");
    if (imageProcessor != null && "Thumbnailator".equals(imageProcessor)) {
        ImageUtils.scaleImage(ori, dest, maxSize);
    }else {
        GMagickUtils.scaleImage(ori, dest, maxSize);
    }
    return true;
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:19,代码来源:ImageHandleUtils.java

示例10: truncateImage

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
public static boolean truncateImage(String ori, String dest, int x, int y, int size) throws IOException, InterruptedException, IM4JavaException {
    String imageProcessor = appContext.getConfig().get("image_processor");
    if (imageProcessor != null && "Thumbnailator".equals(imageProcessor)) {
        return ImageUtils.truncateImage(ori, dest, x, y, size);
    }else {
        return GMagickUtils.truncateImage(ori, dest, x, y, size);
    }
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:9,代码来源:ImageHandleUtils.java

示例11: truncateImage

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
public static boolean truncateImage(String ori, String dest, int width, int height) throws IOException, InterruptedException, IM4JavaException {
    File oriFile = new File(ori);

    validate(oriFile, dest);

    BufferedImage src = ImageIO.read(oriFile); // 读入文件
    int w = src.getWidth();
    int h = src.getHeight();

    int min = Math.min(w, h);
    int side = Math.min(width, height);

    IMOperation op = new IMOperation();
    op.addImage(ori);

    if (w <= width && h <= height) {
        // Don't do anything
    } else if (min < side) {
        op.gravity("center").extent(width, height);
    } else {
        op.resize(width, height, '^').gravity("center").extent(width, height);
    }

    op.addImage(dest);
    ConvertCmd convert = new ConvertCmd(true);
    convert.run(op);
    return true;
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:29,代码来源:ImageUtils.java

示例12: main

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException, IM4JavaException {
    String ori = "F:\\data\\go\\ns10.jpg";
    ImageUtils.truncateImage(ori, "F:\\data\\go\\boot_640x960.jpg", 640, 960);
    ImageUtils.truncateImage(ori, "F:\\data\\go\\boot_640x1136.jpg", 640, 1136);
    ImageUtils.truncateImage(ori, "F:\\data\\go\\boot_750x1334.jpg", 750, 1334);
    ImageUtils.truncateImage(ori, "F:\\data\\go\\boot_1242x2208.jpg", 1242, 2208);
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:8,代码来源:ImageUtilsTest.java

示例13: getCompressedImage

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
/**
 * The <code>getCompressedImage</code> method is used to compress passed image according to compression type LZW, quality 100 and
 * convert image to monochrome i.e., black and white w.r.t isColoredImage passed.
 * 
 * @param isColoredImage true for colored image and false otherwise
 * @param imageUrl image to be converted
 * @return url of converted image from passed image
 */
private String getCompressedImage(boolean isColoredImage, String imageUrl) {
	String newImageUrl = imageUrl;
	if (null != imageUrl && imageUrl.length() > 0) {
		IMOperation imOperation = new IMOperation();

		// Applying default image quality
		imOperation.quality((double) IMAGE_QUALITY);
		imOperation.type(OPERATION_TYPE);
		if (!isColoredImage) {
			imOperation.monochrome();
		}

		// Apply compression
		imOperation.compress(COMPRESSION_TYPE);
		imOperation.addImage(); // place holder for input file
		imOperation.addImage(); // place holder for output file

		// Converting image
		ConvertCmd convert = new ConvertCmd();
		newImageUrl = imageUrl.substring(0, imageUrl.lastIndexOf(DOTS)) + NEW + TIF_EXTENSION;

		try {
			convert.run(imOperation, new Object[] {imageUrl, newImageUrl});
		} catch (org.im4java.core.CommandException commandException) {
			LOGGER.error("IM4JAVA_TOOLPATH is not set for converting images using image magic: " + commandException.toString());
		} catch (IOException ioException) {
			LOGGER.error("Files not found for converting operation of image magic: " + ioException.toString());
		} catch (InterruptedException interruptedException) {
			LOGGER.error("Conversion operation of image magic interrupted in between: " + interruptedException.toString());
		} catch (IM4JavaException im4JavaException) {
			LOGGER.error("Error occurred while converting images using image magic: " + im4JavaException.toString());
		}
	}
	return newImageUrl;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:44,代码来源:MultiPageExecutor.java

示例14: addImageWaterMark

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
/**
 * 图片水印
 * 
 * @param srcPath
 * @param imageMark
 * @param newPath
 * @throws IOException
 * @throws InterruptedException
 * @throws IM4JavaException
 *             下午2:02:51 Administrator void
 *
 */
public static void addImageWaterMark(String srcPath, String imageMark, String newPath) throws IOException, InterruptedException, IM4JavaException {
	IMOperation op = new IMOperation();

	op.addImage(srcPath);
	op.addImage(imageMark);
	op.gravity("southeast").dissolve(100);
	op.addImage(newPath);

	CompositeCmd cmd = new CompositeCmd(GM);

	cmd.run(op);
}
 
开发者ID:lklong,项目名称:imageweb,代码行数:25,代码来源:ImageUtilTest.java

示例15: wrapDeviceFrames

import org.im4java.core.IM4JavaException; //导入依赖的package包/类
public void wrapDeviceFrames(String deviceFrame, String deviceScreenToBeFramed,
                             String framedDeviceScreen)
        throws InterruptedException, IOException, IM4JavaException {
    IMOperation op = new IMOperation();
    op.addImage(deviceFrame);
    op.addImage(deviceScreenToBeFramed);
    op.gravity("center");
    op.composite();
    op.opaque("none");
    op.addImage(framedDeviceScreen);
    ConvertCmd cmd = new ConvertCmd();
    cmd.run(op);
}
 
开发者ID:saikrishna321,项目名称:AppiumTestDistribution,代码行数:14,代码来源:ImageUtils.java


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