使用JMagick压缩图片大小尺寸

Posted by eDWARD at 22:25

  1. 我们经常需要实现图片上传的功能,但是光是上传图片可能还是远远不够的,我们必须对我们上传的图片进行处理,改变大小等等。JMagick是ImageMagick提供的一套使用Java调用ImageMagick的API接口,功能非常强大,下面介绍如果使用这个API处理图片的大小。引入JMagick需要的类库:
  2. 我们需要把图片保存为两个尺寸,这里要提前定义两种常量:
  3. 下面介绍如何使用JMagick,里面用到的ImageUtil稍后会介绍,FileUtil是操作文件的工具类,这里就暂时不介绍了:

    ImageUtil.getMagickImage(byte[] byte)

    processHead(MagickImage source)

    ImageUtil.regulate(MagickImage source)

    ImageUtil.resizePhoto(MagickImage source, String destPathName, int maxWidth, int maxHeight)

    下次介绍打标签的方法。

Filed In 学习路上 | Study | Tags: , , , | Add a Comment »

Your Comments.

Leave your own response

Leave a Reply.

Comment Form.

Fields denoted with a "*" are required. Your comment may require moderation, please be patient.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>




Your Reply.

Use the following link to trackback from your own site:
http://www.zhangzhang.net/2008/01/use-jmagic-resizemagic/trackback/

Spread the word.

Octopus supports RSS feed for this post RSS 2.0 , and Trackbacks from other blogs.


Fatal error: Call to undefined function get_single_sidebar() in /home/zhangzha/public_html/wp-content/themes/octopus/single.php on line 69