diff --git a/photos/problemcases/IMG_0046.JPG b/photos/problemcases/IMG_0046.JPG new file mode 100755 index 0000000..67ed6e2 Binary files /dev/null and b/photos/problemcases/IMG_0046.JPG differ diff --git a/photos/problemcases/IMG_0087.JPG b/photos/problemcases/IMG_0087.JPG new file mode 100644 index 0000000..a83a815 Binary files /dev/null and b/photos/problemcases/IMG_0087.JPG differ diff --git a/photos/problemcases/IMG_0088.JPG b/photos/problemcases/IMG_0088.JPG new file mode 100644 index 0000000..aa85612 Binary files /dev/null and b/photos/problemcases/IMG_0088.JPG differ diff --git a/photos/problemcases/IMG_0089.JPG b/photos/problemcases/IMG_0089.JPG new file mode 100644 index 0000000..9526d1a Binary files /dev/null and b/photos/problemcases/IMG_0089.JPG differ diff --git a/photos/problemcases/IMG_0090.JPG b/photos/problemcases/IMG_0090.JPG new file mode 100644 index 0000000..36cc52f Binary files /dev/null and b/photos/problemcases/IMG_0090.JPG differ diff --git a/photos/problemcases/L1020622.JPG b/photos/problemcases/L1020622.JPG new file mode 100755 index 0000000..2b375ac Binary files /dev/null and b/photos/problemcases/L1020622.JPG differ diff --git a/photos/problemcases/album.properties b/photos/problemcases/album.properties new file mode 100644 index 0000000..490ed78 --- /dev/null +++ b/photos/problemcases/album.properties @@ -0,0 +1,5 @@ +cover=IMG_e121.JPG +file.IMG_e121.JPG.orientation=1 +file.IMG_0046.JPG.orientation=3 +file.L1020622.JPG.orientation=6 + diff --git a/src/org/forkalsrud/album/exif/Dimension.java b/src/org/forkalsrud/album/exif/Dimension.java index b14c231..2b9e83e 100644 --- a/src/org/forkalsrud/album/exif/Dimension.java +++ b/src/org/forkalsrud/album/exif/Dimension.java @@ -7,7 +7,6 @@ package org.forkalsrud.album.exif; /** - * TODO (knut - Mar 16, 2008 2:23:56 PM) - add documentation * * @author knut */ diff --git a/src/org/forkalsrud/album/exif/DirectoryEntry.java b/src/org/forkalsrud/album/exif/DirectoryEntry.java index 662466b..6c305ef 100644 --- a/src/org/forkalsrud/album/exif/DirectoryEntry.java +++ b/src/org/forkalsrud/album/exif/DirectoryEntry.java @@ -28,7 +28,6 @@ import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; import com.drew.imaging.jpeg.JpegMetadataReader; -import com.drew.imaging.jpeg.JpegProcessingException; import com.drew.metadata.Directory; import com.drew.metadata.Metadata; import com.drew.metadata.MetadataException; @@ -135,27 +134,29 @@ public class DirectoryEntry extends Entry { Properties loadFromFile(File propFile) throws IOException { Properties props = new Properties(); - props.load(new FileInputStream(propFile)); + FileInputStream fis = new FileInputStream(propFile); + props.load(fis); + fis.close(); return props; } - Properties generateCache() throws MetadataException, JpegProcessingException, IOException, ParseException { + Properties generateCache() throws IOException { long start = System.currentTimeMillis(); Properties props = new Properties(); generateFileEntries(props); - props.store(new FileOutputStream(cache), "Extra Comments"); + FileOutputStream fos = new FileOutputStream(cache); + props.store(fos, "Extra Comments"); + fos.close(); long end = System.currentTimeMillis(); System.out.println("Time to generate properties for " + file.getPath() + ": " + (end - start)/1000d + " s"); - return props; } void generateFileEntries(Properties props) - throws IOException, MetadataException, JpegProcessingException, ParseException { + throws IOException { - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss"); File[] files = file.listFiles(); for (File f : files) { @@ -174,6 +175,7 @@ public class DirectoryEntry extends Entry { continue; } if (CACHE_FILE.equals(name) || OVERRIDE_FILE.equals(name)) { + // cache.properties and album.properties continue; } if (name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".JPG")) { @@ -194,7 +196,7 @@ public class DirectoryEntry extends Entry { } private Map generateThumbnailProperties(File f) - throws JpegProcessingException, MetadataException, IOException { + throws IOException { HashMap props = new HashMap(); String name = f.getName(); boolean hasDate = false; @@ -283,6 +285,7 @@ public class DirectoryEntry extends Entry { reader.setInput(iis, true); ImageReadParam param = reader.getDefaultReadParam(); BufferedImage img = reader.read(0, param); + iis.close(); return new Dimension(img.getWidth(), img.getHeight()); } diff --git a/src/org/forkalsrud/album/web/PictureScaler.java b/src/org/forkalsrud/album/web/PictureScaler.java index bd86dcb..bf22fb5 100644 --- a/src/org/forkalsrud/album/web/PictureScaler.java +++ b/src/org/forkalsrud/album/web/PictureScaler.java @@ -186,7 +186,6 @@ public class PictureScaler { // The first four are obtained with only flipping X and/or Y // The last four are obtained by rotating 90 degrees and then flipping X and/or Y. // - // TODO: Flipping here completely forgets to translate accordingly, so for example rotation id 3 becomes completely messed up. double[] flipX = new double[] { +1, -1, -1, +1, -1, +1, +1, -1 }; double[] flipY = new double[] { +1, +1, -1, -1, +1, +1, -1, -1 }; @@ -197,8 +196,8 @@ public class PictureScaler { AffineTransform xform = new AffineTransform(); boolean rotate = idx >= 4; + xform.translate(intermediate.getWidth() / 2d, intermediate.getHeight() / 2d); if (rotate) { - xform.translate(intermediate.getWidth() / 2d, intermediate.getHeight() / 2d); xform.rotate(Math.PI / 2); scale = (double)intermediate.getHeight() / img.getWidth(); } else { @@ -206,9 +205,7 @@ public class PictureScaler { } xform.scale(scale, scale); xform.scale(flipX[idx], flipY[idx]); - if (rotate) { - xform.translate(-img.getWidth() / 2d, -img.getHeight() / 2d); - } + xform.translate(-img.getWidth() / 2d, -img.getHeight() / 2d); int imgType = img.getType(); BufferedImage buf2 = new BufferedImage(intermediate.getWidth(), intermediate.getHeight(), imgType);