Merge branch 'master' of ssh://forkalsrud.org/home/gitroot/album
This commit is contained in:
commit
956f2d3b45
3 changed files with 53 additions and 2 deletions
11
pom.xml
11
pom.xml
|
|
@ -107,7 +107,7 @@
|
|||
<dependency>
|
||||
<groupId>com.drewnoakes</groupId>
|
||||
<artifactId>metadata-extractor</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>2.4.0-beta-1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
|
|
@ -129,7 +129,7 @@
|
|||
<dependency>
|
||||
<groupId>com.sleepycat</groupId>
|
||||
<artifactId>je</artifactId>
|
||||
<version>4.0.92</version>
|
||||
<version>4.0.103</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency><groupId>com.caucho</groupId><artifactId>resin</artifactId><version>3.1.8</version></dependency>
|
||||
|
|
@ -192,6 +192,13 @@
|
|||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ public class Dimension {
|
|||
}
|
||||
|
||||
|
||||
public Dimension(String width, String height) {
|
||||
this(Integer.parseInt(width), Integer.parseInt(height));
|
||||
}
|
||||
|
||||
public Dimension doubled() {
|
||||
|
||||
return new Dimension(w * 2, h * 2);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ import javax.imageio.ImageReadParam;
|
|||
import javax.imageio.ImageReader;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.forkalsrud.album.db.DirectoryProps;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -94,6 +96,12 @@ public class DirectoryMetadataGenerator {
|
|||
props.setProperty("dir." + name, "present");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param f the jpeg file
|
||||
* @return a map with the following keys: orientation dimensions captureDate comment etag
|
||||
* @throws IOException
|
||||
*/
|
||||
private Map<String, String> generateThumbnailProperties(File f) throws IOException {
|
||||
|
||||
HashMap<String, String> props = new HashMap<String, String>();
|
||||
|
|
@ -159,6 +167,38 @@ public class DirectoryMetadataGenerator {
|
|||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param f the jpeg file
|
||||
* @return a map with the following keys: orientation dimensions captureDate comment etag
|
||||
* @throws IOException
|
||||
*/
|
||||
private Map<String, String> generateVideoProperties(File f) throws IOException {
|
||||
Map<String, String> props = new HashMap<String, String>();
|
||||
ProcessBuilder pb = new ProcessBuilder().command(
|
||||
"mplayer", "-vo", "null", "-ao", "null", "-frames", "0", "-identify", f.getAbsolutePath());
|
||||
pb.redirectErrorStream(false);
|
||||
Process p = pb.start();
|
||||
p.getOutputStream().close();
|
||||
List<String> lines = IOUtils.readLines(p.getInputStream());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
||||
String width = "", height = "";
|
||||
for (String line : lines) {
|
||||
int pos = line.indexOf('=');
|
||||
if (pos >= 0) {
|
||||
String name = line.substring(0, pos);
|
||||
String value = line.substring(pos + 1);
|
||||
if (name.equals("ID_VIDEO_WIDTH")) width = value;
|
||||
if (name.equals("ID_VIDEO_HEIGHT")) height = value;
|
||||
}
|
||||
}
|
||||
props.put("orientation", "1");
|
||||
props.put("dimensions", new Dimension(width, height).toString());
|
||||
props.put("captureDate", sdf.format(new Date(f.lastModified())));
|
||||
props.put("etag", Integer.toHexString(f.getName().hashCode() + Long.valueOf(f.lastModified()).hashCode()));
|
||||
return props;
|
||||
}
|
||||
|
||||
private Date getExifDate(Directory exifDirectory, int tagName) throws MetadataException {
|
||||
|
||||
String dateStr = (String)exifDirectory.getObject(tagName);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue