Use OpenIMAJ for loading images because Java standard library is buggy
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 4 Apr 2020 11:36:46 +0000 (14:36 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 4 Apr 2020 11:36:46 +0000 (14:36 +0300)
pom.xml
src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java

diff --git a/pom.xml b/pom.xml
index 9ad5714..9ca1fcf 100644 (file)
--- a/pom.xml
+++ b/pom.xml
             <artifactId>tika-core</artifactId>
             <version>1.18</version>
         </dependency>
+        <dependency>
+            <groupId>org.openimaj</groupId>
+            <artifactId>core-image</artifactId>
+            <version>1.3.5</version>
+        </dependency>
     </dependencies>
 
     <build>
index ba0d23c..172ec44 100755 (executable)
@@ -28,7 +28,8 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.zip.CRC32;
 
-import static javax.imageio.ImageIO.read;
+import static org.openimaj.image.ImageUtilities.createBufferedImage;
+import static org.openimaj.image.ImageUtilities.readMBF;
 
 public class Utils {
     private static File lastLoadedFile;
@@ -46,8 +47,7 @@ public class Utils {
         if (file.equals(lastLoadedFile))
             return lastLoadedBufferedImage;
 
-        System.out.println("Loading image: " + file.getPath());
-        lastLoadedBufferedImage = read(file);
+        lastLoadedBufferedImage = createBufferedImage(readMBF(file));
         lastLoadedFile = file;
 
         if (lastLoadedBufferedImage == null) {