bump up lib/metadata-extractor-2.6.2.jar (used for image parser) with needed code adjustments

pull/1/head
reger 12 years ago
parent 9a6fcdf597
commit 3760e2616b

@ -83,7 +83,7 @@
<string>$JAVAROOT/lib/lucene-queryparser-4.3.0.jar</string>
<string>$JAVAROOT/lib/lucene-spatial-4.3.0.jar</string>
<string>$JAVAROOT/lib/lucene-suggest-4.3.0.jar</string>
<string>$JAVAROOT/lib/metadata-extractor-2.4.0-beta-1.jar</string>
<string>$JAVAROOT/lib/metadata-extractor-2.6.2.jar</string>
<string>$JAVAROOT/lib/mysql-connector-java-5.1.12-bin.jar</string>
<string>$JAVAROOT/lib/noggit-0.5.jar</string>
<string>$JAVAROOT/lib/pdfbox-1.8.1.jar</string>

@ -202,7 +202,7 @@
<pathelement location="${lib}/lucene-queryparser-4.3.0.jar" />
<pathelement location="${lib}/lucene-spatial-4.3.0.jar" />
<pathelement location="${lib}/lucene-suggest-4.3.0.jar" />
<pathelement location="${lib}/metadata-extractor-2.4.0-beta-1.jar" />
<pathelement location="${lib}/metadata-extractor-2.6.2.jar" />
<pathelement location="${lib}/mysql-connector-java-5.1.12-bin.jar" />
<pathelement location="${lib}/noggit-0.5.jar" />
<pathelement location="${lib}/pdfbox-1.8.1.jar" />

@ -0,0 +1,35 @@
Copyright 2002-2013 Drew Noakes
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
More information about this project is available at:
http://drewnoakes.com/code/exif/
http://code.google.com/p/metadata-extractor/

Binary file not shown.

@ -54,9 +54,9 @@ import net.yacy.kelondro.util.FileUtils;
import com.drew.imaging.jpeg.JpegProcessingException;
import com.drew.imaging.jpeg.JpegSegmentReader;
import com.drew.lang.ByteArrayReader;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.MetadataException;
import com.drew.metadata.Tag;
import com.drew.metadata.exif.ExifReader;
import com.drew.metadata.iptc.IptcReader;
@ -128,30 +128,31 @@ public class genericImageParser extends AbstractParser implements Parser {
JpegSegmentReader segmentReader;
try {
segmentReader = new JpegSegmentReader(new ByteArrayInputStream(b));
/**/
segmentReader = new JpegSegmentReader(b);
final byte[] exifSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APP1);
final byte[] iptcSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APPD);
final Metadata metadata = new Metadata();
new ExifReader(exifSegment).extract(metadata);
new IptcReader(iptcSegment).extract(metadata);
if (exifSegment != null) new ExifReader().extract(new ByteArrayReader(exifSegment),metadata);
if (iptcSegment != null) new IptcReader().extract(new ByteArrayReader(iptcSegment),metadata);
/**/
// alternative to above: to read all included jpeg tags and metadata
// final Metadata metadata = JpegMetadataReader.readMetadata(new ByteArrayInputStream(b));
@SuppressWarnings("unchecked")
final
Iterator<Directory> directories = metadata.getDirectoryIterator();
final Iterator<Directory> directories = metadata.getDirectories().iterator();
final HashMap<String, String> props = new HashMap<String, String>();
while (directories.hasNext()) {
final Directory directory = directories.next();
@SuppressWarnings("unchecked")
final
Iterator<Tag> tags = directory.getTagIterator();
final Iterator<Tag> tags = directory.getTags().iterator();
while (tags.hasNext()) {
final Tag tag = tags.next();
try {
// ! startswith "Unknown tag"
if (!tag.getTagName().startsWith("Unknown")) { // filter out returned TagName of "Unknown tag"
props.put(tag.getTagName(), tag.getDescription());
ii.info.append(tag.getTagName() + ": " + tag.getDescription() + " .\n");
} catch (final MetadataException e) {
//Log.logException(e);
}
}
title = props.get("Image Description");

Loading…
Cancel
Save