Class ImageUtil


  • public class ImageUtil
    extends Object
    A class that validate if these image files {JPEG, PNG) files are valid.
    • Constructor Detail

      • ImageUtil

        public ImageUtil()
    • Method Detail

      • isJPEG

        public boolean isJPEG​(String jpegBase,
                              URL parentURL)
                       throws Exception
        Check if a JPEG file is valid by inspecting the first 2 bytes for 0xffd8 and last 2 bytes for 0xffd9.
        Parameters:
        jpegBase - The basename of the JPEG file
        parentURL - The URL of the parent of basename
        Returns:
        true if the JPEG file is valid false otherwise
        Throws:
        Exception
      • isPNG

        public boolean isPNG​(String pngBase,
                             URL parentURL)
                      throws Exception
        Check if a PNG file is valid by inspecting if the 1st group 4 bytes are 0x89504e47 and the 2nd group of 4 bytes are 0x0d0a1a0a
        Parameters:
        pngBase - The basename of the PNG file
        parentURL - The URL of the parent of basename
        Returns:
        true if the PNG file is valid false otherwise
        Throws:
        Exception