Ticket #11867: GeoImageLayer_noExifOrientation.patch

File GeoImageLayer_noExifOrientation.patch, 1.5 KB (added by holgermappt, 11 years ago)

Fix for images without EXIF orientation.

  • src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java

     
    8484        final int w = img.getWidth(null);
    8585        final int h = img.getHeight(null);
    8686        final int hh, ww;
    87         if (ExifReader.orientationSwitchesDimensions(entry.getExifOrientation())) {
     87        final Integer exifOrientation = entry.getExifOrientation();
     88        if (exifOrientation != null && ExifReader.orientationSwitchesDimensions(exifOrientation)) {
    8889            ww = h;
    8990            hh = w;
    9091        } else {
     
    9899        BufferedImage scaledBI = new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB);
    99100        Graphics2D g = scaledBI.createGraphics();
    100101
    101         final AffineTransform restoreOrientation = ExifReader.getRestoreOrientationTransform(entry.getExifOrientation(), w, h);
    102102        final AffineTransform scale = AffineTransform.getScaleInstance((double) targetSize.width / ww, (double) targetSize.height / hh);
    103         scale.concatenate(restoreOrientation);
     103        if (exifOrientation != null) {
     104            final AffineTransform restoreOrientation = ExifReader.getRestoreOrientationTransform(exifOrientation, w, h);
     105            scale.concatenate(restoreOrientation);
     106        }
    104107
    105108        while (!g.drawImage(img, scale, null)) {
    106109            try {