Java BufferedImage Width Get getWidth(File file)

Here you can find the source of getWidth(File file)

Description

get Width

License

Open Source License

Declaration

public static int getWidth(File file) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Main {

    public static int getWidth(File file) {
        BufferedImage bufImg = getBufferedImage(file);
        if (bufImg != null) {
            return bufImg.getWidth();
        }/*  www.j  av a  2  s  .  c o  m*/
        return 0;
    }

    public static BufferedImage getBufferedImage(File file) {
        try {
            return ImageIO.read(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getWidth(BufferedImage image)