使用Jimi处理图像

来源:互联网 发布:暗黑地牢存档位置mac 编辑:程序博客网 时间:2024/06/06 15:46

Jimi是Java的图像管理类库,主要提供的是Image IO的功能,其前身是Activated Intelligence。Jimi支持包括GIF, JPEG, TIFF, PNG, PICT, Photoshop, BMP, Targa, ICO, CUR, Sunraster, XBM, XPM, and PCX在内的各种格式图像。

 

官方地址:http://java.sun.com/products/jimi/

 

最简单的方式:

package test;

import java.awt.Image;

import com.sun.jimi.core.Jimi;
import com.sun.jimi.core.JimiException;


public class ImageHelper {
 
 /**
  * 转换图片格式,基于jimi.jar
  * @param oldFile
  * @param newFile
  * @return
  */
 public static boolean convertImageFormat(String oldFile,String newFile)
 {
  boolean isok = true;
  try {
   Image img=Jimi.getImage(oldFile);
   Jimi.putImage(img,newFile);
  } catch (JimiException e) {
   isok = false;
   e.printStackTrace();
  }
  return isok;
 }
 
 
}

原创粉丝点击