Class UniqueImageStore

  • All Implemented Interfaces:

    
    public final class UniqueImageStore
    
                        

    Stores images in the given imagesDir, detecting and preventing duplicates.

    The imageFormat is used to write BufferedImages to files, and for the file extension of the images. It can be any format in ImageIO.getWriterFormatNames (at least "png", "jpeg", "gif", "bmp").

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Path saveOrGetPath(BufferedImage image) Ensures the given image is saved in this store and returns its Path.
      final Path saveOrGetPath(ByteArray imageBytes) Ensures the given image is saved in this store and returns its Path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UniqueImageStore

        UniqueImageStore(Path imagesDir, String imageFormat)
    • Method Detail

      • saveOrGetPath

         final Path saveOrGetPath(BufferedImage image)

        Ensures the given image is saved in this store and returns its Path.

        If an identical image already exists, the existing file is kept and its path is returned. If not, the given image is written as a new file and its path is returned.

      • saveOrGetPath

         final Path saveOrGetPath(ByteArray imageBytes)

        Ensures the given image is saved in this store and returns its Path. The imageBytes must be provided in the correct imageFormat for this store.

        If an identical image already exists, the existing file is kept and its path is returned. If not, the given image is written as a new file and its path is returned.