Ticket #20341: 20341-core-V4.diff
| File 20341-core-V4.diff, 8.8 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java
4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.io.File; 7 import java.io.IOException; 7 8 import java.util.Date; 8 9 import java.util.List; 10 import java.util.Locale; 9 11 import java.util.Objects; 10 12 import java.util.function.Consumer; 11 13 … … 18 20 import org.openstreetmap.josm.tools.Logging; 19 21 20 22 import com.drew.imaging.jpeg.JpegMetadataReader; 23 import com.drew.imaging.jpeg.JpegProcessingException; 21 24 import com.drew.imaging.png.PngMetadataReader; 25 import com.drew.imaging.png.PngProcessingException; 22 26 import com.drew.imaging.tiff.TiffMetadataReader; 27 import com.drew.imaging.tiff.TiffProcessingException; 23 28 import com.drew.metadata.Directory; 24 29 import com.drew.metadata.Metadata; 25 30 import com.drew.metadata.MetadataException; … … 587 592 588 593 try { 589 594 // try to parse metadata according to extension 590 String ext = fn.substring(fn.lastIndexOf( ".") + 1).toLowerCase();595 String ext = fn.substring(fn.lastIndexOf('.') + 1).toLowerCase(Locale.US); 591 596 switch (ext) { 592 597 case "jpg": 593 598 case "jpeg": … … 603 608 default: 604 609 throw new NoMetadataReaderWarning(ext); 605 610 } 606 } catch (Exception topException) { 611 } catch (JpegProcessingException | TiffProcessingException | PngProcessingException | IOException 612 | NoMetadataReaderWarning topException) { 607 613 //try other formats (e.g. JPEG file with .png extension) 608 614 try { 609 615 metadata = JpegMetadataReader.readMetadata(file); 610 } catch ( Exception ex1) {616 } catch (JpegProcessingException | IOException ex1) { 611 617 try { 612 618 metadata = TiffMetadataReader.readMetadata(file); 613 } catch ( Exception ex2) {619 } catch (TiffProcessingException | IOException ex2) { 614 620 try { 615 621 metadata = PngMetadataReader.readMetadata(file); 616 } catch ( Exception ex3) {622 } catch (PngProcessingException | IOException ex3) { 617 623 618 624 Logging.warn(topException); 619 625 Logging.info(tr("Can''t parse metadata for file \"{0}\". Using last modified date as timestamp.", fn)); -
src/org/openstreetmap/josm/gui/io/importexport/ImageImporter.java
7 7 import java.io.IOException; 8 8 import java.util.ArrayList; 9 9 import java.util.Arrays; 10 import java.util.Collections; 10 11 import java.util.HashSet; 11 12 import java.util.List; 12 13 import java.util.Set; 14 import java.util.stream.Collectors; 13 15 14 16 import javax.imageio.ImageIO; 15 17 … … 29 31 /** 30 32 * The supported image file types on the current system 31 33 */ 32 public static final String[] SUPPORTED_FILE_TYPES = ImageIO.getReaderFileSuffixes(); 34 public static final List<String> SUPPORTED_FILE_TYPES = Collections 35 .unmodifiableList(Arrays.stream(ImageIO.getReaderFileSuffixes()).sorted().collect(Collectors.toList())); 33 36 34 37 /** 35 38 * The default file filter -
src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
242 242 } 243 243 244 244 private boolean updateImageEntry(Image img) { 245 if (img == null) { 246 synchronized (ImageDisplay.this) { 247 errorLoading = true; 248 ImageDisplay.this.repaint(); 249 return false; 250 } 251 } 245 252 if (!(entry.getWidth() > 0 && entry.getHeight() > 0)) { 246 253 synchronized (entry) { 247 254 int width = img.getWidth(this);
