Fixed some scaling issues (notably for orientation==3)
This commit is contained in:
parent
0adfb5b485
commit
f34f3f4c24
10 changed files with 18 additions and 14 deletions
BIN
photos/problemcases/IMG_0046.JPG
Executable file
BIN
photos/problemcases/IMG_0046.JPG
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
BIN
photos/problemcases/IMG_0087.JPG
Normal file
BIN
photos/problemcases/IMG_0087.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 565 KiB |
BIN
photos/problemcases/IMG_0088.JPG
Normal file
BIN
photos/problemcases/IMG_0088.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 560 KiB |
BIN
photos/problemcases/IMG_0089.JPG
Normal file
BIN
photos/problemcases/IMG_0089.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 574 KiB |
BIN
photos/problemcases/IMG_0090.JPG
Normal file
BIN
photos/problemcases/IMG_0090.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 534 KiB |
BIN
photos/problemcases/L1020622.JPG
Executable file
BIN
photos/problemcases/L1020622.JPG
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
5
photos/problemcases/album.properties
Normal file
5
photos/problemcases/album.properties
Normal file
|
|
@ -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
|
||||
|
||||
|
|
@ -7,7 +7,6 @@ package org.forkalsrud.album.exif;
|
|||
|
||||
|
||||
/**
|
||||
* TODO (knut - Mar 16, 2008 2:23:56 PM) - add documentation
|
||||
*
|
||||
* @author knut
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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<String, String> generateThumbnailProperties(File f)
|
||||
throws JpegProcessingException, MetadataException, IOException {
|
||||
throws IOException {
|
||||
HashMap<String, String> props = new HashMap<String, String>();
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue