- /**
- * Picture dimensions.
- */
- private Dimension dimensions;
-
- public Picture(final File parentDirectory, final String fileName)
- throws IOException, ImageFormatError {
- super(parentDirectory, fileName);
- }
-
- private String computeThumbnailHash(final Dimension targetDimension) {
-
- // compute new thumbnails hash number
- final String forMagicHash = fileName + " "
- + String.valueOf(targetDimension.width) + " "
- + String.valueOf(targetDimension.height) + " "
- + String.valueOf(getFileLength()) + " "
- + Constants.THUMBNAIL_VERSION;
-
- // System.out.println("Computing hash from: " + forMagicHash);
- return Utils.getStringCrcAsHex(forMagicHash);
- }
-
- public Dimension getDimensions() {
- return dimensions;
- };
-
- /**
- * Get thumbnail file name for this image and desired thumbnail dimensions
- * relative to designated thumbnails directory within parent directory.
- */
- public String getRelativeThumbnailFileName(final Dimension targetDimension) {
- return FilePathParser.getFileNameWithoutExtension(fileName) + " ("
- + computeThumbnailHash(targetDimension) + ").jpeg";
- }
-
- @Override
- public void updateFileMetainfo(final File parentDirectory)
- throws IOException {
- BufferedImage image;
- try {
- image = Utils.getBufferedImage(getFile(parentDirectory));
- } catch (final ImageFormatError e) {
- throw new RuntimeException(e);
- }
- dimensions = new Dimension(image.getWidth(), image.getHeight());