Java Image Height Get getHeight(final File image)

Here you can find the source of getHeight(final File image)

Description

Return image height in pixels.

License

Mozilla Public License

Parameter

Parameter Description
image image file.

Exception

Parameter Description
IOException Failed to read the image.

Return

Image height in pixels.

Declaration

public static int getHeight(final File image) throws IOException 

Method Source Code

//package com.java2s;
/*//from   w  w w .ja  va  2  s.  c  o  m
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * If applicable, add the following below this MPL 2.0 HEADER, replacing
 * the fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *     Portions Copyright [yyyy] [name of copyright owner]
 *
 *     Copyright 2013-2014 ForgeRock AS
 *
 */

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Main {
    /**
     * Return image height in pixels.
     *
     * @param image image file.
     * @throws IOException Failed to read the image.
     * @return Image height in pixels.
     */
    public static int getHeight(final File image) throws IOException {
        BufferedImage bufferedImage = ImageIO.read(image);
        return bufferedImage.getHeight();
    }
}

Related

  1. getHeight(final Image image)
  2. getHeight(Image pImage)
  3. getHeight(java.awt.Image image)