Class UniqueImageStore
-
- All Implemented Interfaces:
public final class UniqueImageStoreStores 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").
-
-
Constructor Summary
Constructors Constructor Description UniqueImageStore(Path imagesDir, String imageFormat)
-
Method Summary
Modifier and Type Method Description final PathsaveOrGetPath(BufferedImage image)Ensures the given image is saved in this store and returns its Path. final PathsaveOrGetPath(ByteArray imageBytes)Ensures the given image is saved in this store and returns its Path. -
-
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.
-
-
-
-