public static Dimension getImageSize(final byte[] bytes) throws ImagingException, IOException {
        return getImageSize(ByteSource.array(bytes));
    }
Determines the width and height of an image.

@param bytes Byte array containing an image file.
@return The width and height of the image.
@throws ImagingException if it fails to parse the image
@throws IOException      if it fails to read the image data
src/main/java/org/apache/commons/imaging/Imaging.java