Code refactoring. Generate image thumbnails with same extension as original image.
[meviz.git] / src / main / java / eu / svjatoslav / meviz / htmlindexer / metadata / fileTypes / Picture.java
index ae22071..9f35743 100755 (executable)
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import static eu.svjatoslav.meviz.htmlindexer.Utils.getBufferedImage;
+import static java.awt.image.BufferedImage.TYPE_INT_RGB;
 
 public class Picture extends AbstractFile {
 
@@ -122,7 +123,7 @@ public class Picture extends AbstractFile {
 
             final BufferedImage bufferedImage = new BufferedImage(
                     scaledImage.getWidth(null), scaledImage.getHeight(null),
-                    BufferedImage.TYPE_INT_RGB);
+                    TYPE_INT_RGB);
 
             final Graphics2D g = bufferedImage.createGraphics();
             g.drawImage(scaledImage, 0, 0, null);
@@ -158,9 +159,9 @@ public class Picture extends AbstractFile {
 
         // compute new thumbnails hash number
         final String forMagicHash = fileName + " "
-                + String.valueOf(targetDimension.width) + " "
-                + String.valueOf(targetDimension.height) + " "
-                + String.valueOf(getFileLength()) + " "
+                + targetDimension.width + " "
+                + targetDimension.height + " "
+                + getFileLength() + " "
                 + Constants.THUMBNAIL_VERSION;
 
         // System.out.println("Computing hash from: " + forMagicHash);
@@ -177,7 +178,7 @@ public class Picture extends AbstractFile {
      */
     public String getRelativeThumbnailFileName(final Dimension targetDimension) {
         return FilePathParser.getFileNameWithoutExtension(fileName) + " ("
-                + computeThumbnailHash(targetDimension) + ").jpeg";
+                + computeThumbnailHash(targetDimension) + ")." + getFileExtension();
     }
 
     @Override