当前位置:编程学习 > JSP >>

Imagemagick备忘

答案:
裁剪用-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

上一个:Struts心得—DispatchAction使用日记
下一个:我的乱码之路——JSP与MySQL交互的中文乱码解决方案及总结

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,