public static Dimension getImageSize(final ByteSource byteSource) throws ImagingException, IOException {
        final AbstractImageParser<?> imageParser = ImageParserFactory.getImageParser(byteSource);
        return imageParser.getImageSize(byteSource, null);
    }
Determines the width and height of an image byte source.

@param byteSource Byte source data.
@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