Class ImageMimeInfo

java.lang.Object
org.bzdev.imageio.ImageMimeInfo

public class ImageMimeInfo extends Object
Information about MIME types for writable images handled by javax.imageio classes. The methods are all static.

Note: The term "MIME type" is the historic one. Current IETF usage has replaced this with "media type".

  • Constructor Details

    • ImageMimeInfo

      public ImageMimeInfo()
  • Method Details

    • getMIMETypeForSuffix

      public static String getMIMETypeForSuffix(String suffix)
      Get the MIME type for a suffix. The suffix does not include the period separating it from the rest of a file name. The mapping is not case sensitive. The rationale for not distinguishing between upper and lower case characters is that image file are sometimes imported from external sources (e.g., a digital camera) that may use a different convention regarding the case of file names.
      Parameters:
      suffix - the suffix
      Returns:
      the MIME type; null if the suffix is not recognized as one used for image files
    • getMimeToSuffixesEntrySet

      public static Set<Map.Entry<String,String[]>> getMimeToSuffixesEntrySet()
      Get the entry set mapping mime types to the corresponding suffixes.
      Returns:
      the entry set
    • numberOfSuffixes

      public static int numberOfSuffixes()
      Get the number of suffixes
      Returns:
      the number of suffixes
    • getSuffixEntrySet

      public static Set<Map.Entry<String,String>> getSuffixEntrySet()
      Get a set of Map.Entry<String,String> containing each entry in the suffix to MIME type map.
      Returns:
      a set of of Map.Entry<String,String> representing the entries in the suffix to MIME type map.
    • getSuffixSet

      public static Set<String> getSuffixSet()
      Get a set of all suffixes for writable formats.
      Returns:
      the set of file suffixes
    • getExtensionForMimeType

      public static String getExtensionForMimeType(String mtype)
      Get the file extension matching a MIME type.
      Parameters:
      mtype - the MIME type
      Returns:
      the file extension
    • getFilenameExtension

      public static String getFilenameExtension(File file)
      Get the extension for a file.
      Parameters:
      file - the file
      Returns:
      the file extension; null if there is no extension; an empty string if the file name ends in a period
    • getFilenameExtension

      public static String getFilenameExtension(String filename)
      Get the extension for a file name.
      Parameters:
      filename - the filename
      Returns:
      the file extension; null if there is no extension; an empty string if the file name ends in a period
    • getFormatNameForFile

      public static String getFormatNameForFile(File file)
      Get the format name given a file. The format name is determined by the file's extension.
      Parameters:
      file - the file
      Returns:
      the format name for the file; null if there is none or if the format is not recognized by Java
    • getFormatNameForFile

      public static String getFormatNameForFile(String filename)
      Get the format name given a file. The format name is determined by the file's extension.
      Parameters:
      filename - the file name
      Returns:
      the format name for the file; null if there is none or if the format is not recognized by Java
    • getFormatNameForSuffix

      public static String getFormatNameForSuffix(String suffix)
      Get the format name given a file-name extension or suffix.
      Parameters:
      suffix - the suffix or file-name extension
      Returns:
      the format name; null if there is none or if the format is not recognized by Java
    • getAllExt

      public static String[] getAllExt()
      Get all suffixes (file extensions) associated with Java-supported images that can be used for writing files.
      Returns:
      a set of file name suffixes
    • supportsMIMEType

      public static boolean supportsMIMEType(String mimeType)
      Determine if a MIME type is supported.
      Parameters:
      mimeType - a MIME type
      Returns:
      true if the MIME type is supported by javax.imageio operations; false otherwise
    • getFormatNameForMimeType

      public static String getFormatNameForMimeType(String mimeType)
      Get the javax.imageio format name matching a MIME type.
      Parameters:
      mimeType - a MIME type
      Returns:
      a standard javax.imageio format name matching the MIME type
    • getSuffixes

      public static String[] getSuffixes(String mimeType)
      Get the suffixes matching a MIME type.
      Parameters:
      mimeType - a MIME type
      Returns:
      the suffixes for the MIME type
    • getMimeType

      public static String getMimeType(String name)
      Get the MIME type for a format name
      Parameters:
      name - the format name
      Returns:
      the MIME type matching a format name.
    • getFormatNames

      public static Set<String> getFormatNames()
      Get the names of the formats supported by the javax.imageio package. There are typically multiple names corresponding to the same MIME type.
      Returns:
      an unmodifiable set containing the names
    • getMimeTypes

      public static Set<String> getMimeTypes()
      Get the MIME types of the image types supported by the javax.imageio package.
      Returns:
      an unmodifiable set containing the MIME types