Imagemagick备忘

类别:Java 点击:0 评论:0 推荐:

裁剪用-crop,jpg没问题,不过遇到gif就要注意了

例如下图:

裁剪只裁剪图片内容,不能消除背景的size,

convert image1.gif -crop 75x75+0+0 image2.gif

结果如下图片

解决办法使用+repage参数

convert image1.gif -crop 75x75+0+0 +repage image2.gif

75x75是结果的size,+0+0是图片在画布中间的偏移量,用了+repage会清空图片以外的空白

不过在jmagick的接口中没找到如何把+repage参数传递进去

    /**
     * Creates a new image that is a subregion of the original.
     *
     * @param chopInfo the subimage
     * @return a subimage of the original
     * @exception MagickException on error
     */
    public native MagickImage cropImage(Rectangle chopInfo)
 throws MagickException;

Rectangle只带了坐标信息,所以我现在切的gif图片size没办法去除所谓的“page geometry ”

这里说下不带偏移量的裁剪,效果很奇特,整个gif加载的时候会滚动在75x75的窗口中最后停下来

convert image1.gif -crop 75x75 +repage image2.gif

参考:http://www.cit.gu.edu.au/~anthony/graphics/imagick6/crop/#crop_repage

本文地址:http://com.8s8s.com/it/it10613.htm