Java Code Examples for org.im4java.core.IMOperation#crop()

The following examples show how to use org.im4java.core.IMOperation#crop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageUtil.java    From im4java-util with Artistic License 2.0 5 votes vote down vote up
/**
 * 将图片分割为若干小图
 * 
 * @param srcImagePath 源图片路径
 * @param destImagePath 目标图片路径
 * @param width 指定宽度(默认为完整宽度)
 * @param height 指定高度(默认为完整高度)
 * @return 小图路径
 * @throws Exception
 */
public static List<String> subsection(String srcImagePath, String destImagePath, Integer width,
        Integer height) throws Exception {
    IMOperation op = new IMOperation();
    op.addImage(srcImagePath);
    op.crop(width, height);
    op.addImage(createDirectory(destImagePath));

    ImageCommand cmd = getImageCommand(CommandType.convert);
    cmd.run(op);

    return getSubImages(destImagePath);
}
 
Example 2
Source File: ImageUtil.java    From im4java-util with Artistic License 2.0 3 votes vote down vote up
/**
 * 从原图中裁剪出新图
 * 
 * @param srcImagePath 源图片路径
 * @param destImagePath 目标图片路径
 * @param x 原图左上角
 * @param y 原图左上角
 * @param width 新图片宽度
 * @param height 新图片高度
 * @throws Exception
 */
public static void crop(String srcImagePath, String destImagePath, int x, int y, int width,
        int height) throws Exception {
    IMOperation op = new IMOperation();
    op.addImage(srcImagePath);
    op.crop(width, height, x, y);
    op.addImage(createDirectory(destImagePath));
    ImageCommand cmd = getImageCommand(CommandType.convert);
    cmd.run(op);
}