import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class CheckImagesFormatUtil {
/**
* 图片的像素判断
* @param file 文件
* @param imageWidth 图片宽度
* @param imageHeight 图片高度
* @return true:上传图片宽度和高度都小于等于规定最大值
* @throws IOException
*/
public static boolean checkImageElement(File file, int imageWidth, int imageHeight) throws IOException {
Boolean result = false;
if (!file.exists()) {
return false;
}
BufferedImage bufferedImage = ImageIO.read(file);
int width = bufferedImage.getWidth();
int height = bufferedImage.getHeight();
if (bufferedImage != null && height == imageHeight && width == imageWidth) {