Revision: 6672
          http://sourceforge.net/p/jump-pilot/code/6672
Author:   michaudm
Date:     2021-02-09 07:09:11 +0000 (Tue, 09 Feb 2021)
Log Message:
-----------
try catch getImageInfo for the case it can't be parsed by commons imaging

Modified Paths:
--------------
    core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java

Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java  
2021-02-08 22:57:44 UTC (rev 6671)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java  
2021-02-09 07:09:11 UTC (rev 6672)
@@ -25,6 +25,7 @@
 import javax.media.jai.JAI;
 
 import com.vividsolutions.jump.workbench.model.Disposable;
+import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.Imaging;
 import org.openjump.core.ccordsys.utils.SRSInfo;
 import org.openjump.util.metaData.MetaDataMap;
@@ -352,7 +353,13 @@
                     if (imageFileName.toLowerCase().endsWith(".flt")) 
bitsPerPixel = 16;
                     else if (imageFileName.toLowerCase().endsWith(".asc")) 
bitsPerPixel = 16;
                     else if (imageFileName.toLowerCase().endsWith(".txt")) 
bitsPerPixel = 16;
-                    else bitsPerPixel = Imaging.getImageInfo(new 
File(imageFileName)).getBitsPerPixel();
+                    else {
+                        try {
+                            bitsPerPixel = Imaging.getImageInfo(new 
File(imageFileName)).getBitsPerPixel();
+                        } catch(ImageReadException e) {
+                            Logger.warn("Can't get ImageInfo of " + 
imageFileName, e);
+                        }
+                    }
                 }
                 clearImageAndRaster(true);
                 // Check that there is enough free memory for the image + 1% 
of available memory + 10Mb



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to