Class FileFilters

java.lang.Object
se.datadosen.util.FileFilters

public class FileFilters
extends java.lang.Object
Handle image loading and saving and decide if a certain file is supported by JAlbum
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  FileFilters.BasicImageInfo  
    static class  FileFilters.FileType  
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String AUDIO_FILE  
    static java.lang.String FLASH_VIDEO  
    static java.lang.String MEDIA_FILE  
    static java.lang.String WEB_LOCATION  
    static java.lang.String WEB_PAGE_TEMPLATE  
  • Constructor Summary

    Constructors 
    Constructor Description
    FileFilters()  
  • Method Summary

    Modifier and Type Method Description
    static int calculateSubsamplingByScale​(FileFilters.BasicImageInfo info, java.awt.Dimension imageDim)
    Calculate sub sampling variable for an image.
    static int calculateSubsamplingByScale​(FileFilters.BasicImageInfo info, java.awt.Dimension imageDim, int scaleModifier)
    Calculate subsampling variable for an image.
    static FileFilters.BasicImageInfo getBasicImageInfo​(java.io.File f)  
    static java.lang.String getExtensionOf​(java.io.File f)
    Deprecated.
    Also lowers case of extension.
    static java.lang.String getFileCategory​(java.io.File f)
    Return file category (from filetypes.xml) or null if not category found
    static FileFilters.FileType getFileType​(java.io.File f)  
    static java.io.File getIconFor​(java.io.File f)
    Deprecated.
    Use getIconFor(File f, AlbumBean engine) instead
    static java.io.File getIconFor​(java.io.File f, AlbumBean engine)
    Get icon for given file.
    static java.util.Iterator<javax.imageio.ImageReader> getImageReaders​(java.lang.String fileSuffix, java.lang.Object input)
    Return iterator of ImageReaders based both on file extension (primarily) and content (secondarily)
    static javax.imageio.metadata.IIOMetadata getMetaData​(java.io.File file)  
    static boolean hasIcon​(java.io.File file)  
    static boolean isFileSupported​(java.io.File file)
    Tell if the extension of a specific file is supported by FileFilters.
    static boolean isJPEGImage​(java.io.File f)  
    static boolean isMediaFile​(java.io.File file)
    Deprecated.
    Use hasIcon() instead
    static java.awt.image.BufferedImage loadImage​(java.io.File file)
    Load an image from file.
    static java.awt.image.BufferedImage loadImage​(java.io.File file, int subsampling)
    Load an image from file.
    static java.awt.image.BufferedImage loadImage​(java.io.File file, int subsampling, javax.imageio.ImageReadParam param)
    Load an image from file.
    static java.awt.image.BufferedImage loadImage​(java.io.File file, AlbumBean engine)
    Deprecated.
    Use loadImage(File file) instead.
    static void reorderImageReaders()
    Reorder image readers so more capable readers are used first The CMYKJPEGReader should be put after the standard JPEG image reader
    static byte[] saveImage​(java.awt.image.BufferedImage img, java.io.File file, java.lang.String formatName, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData)  
    static byte[] saveImage​(java.awt.image.BufferedImage img, java.io.File file, java.lang.String formatName, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData, float compressionQuality)  
    static void saveJPEG​(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine)  
    static void saveJPEG​(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData)  
    static byte[] saveJPEG​(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData, float compressionQuality)
    Save image to JPEG file Since jAlbum 8.9: If null is passed as file, then the JPEG image is returned as a byte array instead

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • saveJPEG

      public static void saveJPEG​(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine) throws java.io.IOException
      Throws:
      java.io.IOException
    • saveJPEG

      public static void saveJPEG​(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData) throws java.io.IOException
      Throws:
      java.io.IOException
    • saveJPEG

      public static byte[] saveJPEG​(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData, float compressionQuality) throws java.io.IOException
      Save image to JPEG file Since jAlbum 8.9: If null is passed as file, then the JPEG image is returned as a byte array instead
      Parameters:
      img -
      file - If null, encoded JPEG image will be returned as byte array
      engine -
      metaData -
      compressionQuality -
      Returns:
      null, or byte array of JPEG encoded image if file is null
      Throws:
      java.io.IOException - Throws ImageFormatException
    • saveImage

      public static byte[] saveImage​(java.awt.image.BufferedImage img, java.io.File file, java.lang.String formatName, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData) throws java.io.IOException
      Throws:
      java.io.IOException
    • saveImage

      public static byte[] saveImage​(java.awt.image.BufferedImage img, java.io.File file, java.lang.String formatName, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData, float compressionQuality) throws java.io.IOException
      Throws:
      java.io.IOException
    • isJPEGImage

      public static boolean isJPEGImage​(java.io.File f)
    • getMetaData

      public static javax.imageio.metadata.IIOMetadata getMetaData​(java.io.File file) throws java.io.IOException
      Throws:
      java.io.IOException
    • isFileSupported

      public static boolean isFileSupported​(java.io.File file)
      Tell if the extension of a specific file is supported by FileFilters.
      Returns:
      True if extension is supported, otherwise false.
    • isMediaFile

      @Deprecated public static boolean isMediaFile​(java.io.File file)
      Deprecated.
      Use hasIcon() instead
    • getFileCategory

      public static java.lang.String getFileCategory​(java.io.File f)
      Return file category (from filetypes.xml) or null if not category found
      Since:
      v8
    • getFileType

      public static FileFilters.FileType getFileType​(java.io.File f)
    • hasIcon

      public static boolean hasIcon​(java.io.File file)
    • getIconFor

      @Deprecated public static java.io.File getIconFor​(java.io.File f)
      Deprecated.
      Use getIconFor(File f, AlbumBean engine) instead
    • getIconFor

      public static java.io.File getIconFor​(java.io.File f, AlbumBean engine)
      Get icon for given file. Icons defined in the skin specific res directories have precedence over icons defined in the global res directory
    • getExtensionOf

      @Deprecated public static java.lang.String getExtensionOf​(java.io.File f)
      Deprecated.
      Also lowers case of extension. Use IO.extension
    • getBasicImageInfo

      public static FileFilters.BasicImageInfo getBasicImageInfo​(java.io.File f) throws java.io.IOException
      Throws:
      java.io.IOException
    • loadImage

      @Deprecated public static java.awt.image.BufferedImage loadImage​(java.io.File file, AlbumBean engine) throws java.io.IOException
      Deprecated.
      Use loadImage(File file) instead.
      Load JPEG, GIF and PNG images and others supported by Jimi.
      Throws:
      java.io.IOException
    • loadImage

      public static java.awt.image.BufferedImage loadImage​(java.io.File file) throws java.io.IOException
      Load an image from file.
      Parameters:
      file - Image file.
      Returns:
      BufferedImage representing the image file.
      Throws:
      java.io.IOException - If image load fails.
    • getImageReaders

      public static java.util.Iterator<javax.imageio.ImageReader> getImageReaders​(java.lang.String fileSuffix, java.lang.Object input)
      Return iterator of ImageReaders based both on file extension (primarily) and content (secondarily)
      Parameters:
      input - Usually an ImageInputStream. Ignored if null
      fileSuffix - Search via fileSuffix primarily (RAW readers won't respond to seach via input)
    • loadImage

      public static java.awt.image.BufferedImage loadImage​(java.io.File file, int subsampling) throws java.io.IOException
      Load an image from file.
      Parameters:
      file - Image file.
      subsampling - Subsampling variable, use calculateSubsamplingByScale() to calculate it.
      Returns:
      BufferedImage representing the inage file.
      Throws:
      java.io.IOException - If image load fails.
    • loadImage

      public static java.awt.image.BufferedImage loadImage​(java.io.File file, int subsampling, javax.imageio.ImageReadParam param) throws java.io.IOException
      Load an image from file.
      Parameters:
      file - Image file.
      subsampling - Subsampling variable, use calculateSubsamplingByScale() to calculate it.
      param - Parameters controlling image reading in detail (for instance RAW processing)
      Returns:
      BufferedImage representing the inage file.
      Throws:
      java.io.IOException - If image load fails.
      Since:
      13.1
    • calculateSubsamplingByScale

      public static int calculateSubsamplingByScale​(FileFilters.BasicImageInfo info, java.awt.Dimension imageDim)
      Calculate sub sampling variable for an image.
      Parameters:
      imageDim - Intended output image dimension.
      Returns:
      Calculated subsampling variable.
    • calculateSubsamplingByScale

      public static int calculateSubsamplingByScale​(FileFilters.BasicImageInfo info, java.awt.Dimension imageDim, int scaleModifier)
      Calculate subsampling variable for an image.
      Parameters:
      imageDim - Intended output image dimension.
      scaleModifier - Variable used to control image quality (higher value gives higher quality but slower processing).
      Returns:
      Calculated subsampling variable.
    • reorderImageReaders

      public static void reorderImageReaders()
      Reorder image readers so more capable readers are used first The CMYKJPEGReader should be put after the standard JPEG image reader