BMP and ICO image formats support : integrated /haraldk/TwelveMonkeys

imageio-bmp-3.2 library.

 - better BMP format flavours support
 - handle PNG encoded icons
 - handle transparency
 
Added some javadoc url references to .classpath
pull/26/head
luc 10 years ago
parent b6ba941d33
commit f0478bb14d

@ -1,102 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="test"/>
<classpathentry excluding="api/|env/|processing/domaingraph/applet/|yacy/|api/bookmarks/|api/ymarks/|api/bookmarks/posts/|api/bookmarks/tags/|api/bookmarks/xbel/|solr/|gsa/|solr/collection1/|api/blacklists/" kind="src" path="htroot"/>
<classpathentry excluding="bookmarks/|ymarks/|bookmarks/posts/|bookmarks/tags/|bookmarks/xbel/|blacklists/" kind="src" path="htroot/api"/>
<classpathentry kind="src" path="htroot/env"/>
<classpathentry kind="src" path="htroot/yacy"/>
<classpathentry excluding="posts/|tags/|xbel/" kind="src" path="htroot/api/bookmarks"/>
<classpathentry kind="src" path="htroot/api/ymarks"/>
<classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
<classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
<classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
<classpathentry kind="src" path="htroot/api/blacklists"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="lib/J7Zip-modified.jar"/>
<classpathentry kind="lib" path="lib/webcat-0.1-swf.jar"/>
<classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
<classpathentry kind="lib" path="lib/jsch-0.1.53.jar"/>
<classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/json-simple-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.10.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="lib/jaudiotagger-2.0.4-20111207.115108-15.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="lib/jcl-over-slf4j-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/log4j-over-slf4j-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.4.jar"/>
<classpathentry kind="lib" path="lib/metadata-extractor-2.8.1.jar"/>
<classpathentry kind="lib" path="lib/xmpcore-5.1.2.jar"/>
<classpathentry kind="lib" path="lib/jcifs-1.3.17.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
<classpathentry kind="lib" path="lib/spatial4j-0.4.1.jar"/>
<classpathentry kind="lib" path="lib/zookeeper-3.4.6.jar"/>
<classpathentry kind="lib" path="lib/org.restlet.jar"/>
<classpathentry kind="lib" path="lib/fontbox-1.8.10.jar"/>
<classpathentry kind="lib" path="lib/jempbox-1.8.10.jar"/>
<classpathentry kind="lib" path="lib/pdfbox-1.8.10.jar"/>
<classpathentry kind="lib" path="lib/bcmail-jdk15-1.46.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15-1.46.jar"/>
<classpathentry kind="lib" path="lib/poi-3.13-20150929.jar"/>
<classpathentry kind="lib" path="lib/poi-scratchpad-3.13-20150929.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/chardet.jar"/>
<classpathentry kind="lib" path="lib/jetty-client-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-continuation-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-deploy-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-http-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-io-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-jmx-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-proxy-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-security-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-server-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-servlet-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-servlets-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-util-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-webapp-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-xml-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.5.1.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.5.1.jar"/>
<classpathentry kind="lib" path="lib/noggit-0.6.jar"/>
<classpathentry kind="lib" path="lib/solr-core-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/solr-solrj-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/stax2-api-3.1.4.jar"/>
<classpathentry kind="lib" path="lib/woodstox-core-asl-4.4.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-analyzers-common-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-analyzers-phonetic-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-classification-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-codecs-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-core-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-facet-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-grouping-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-highlighter-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-join-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-memory-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-misc-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-queries-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-queryparser-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-spatial-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-suggest-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-backward-codecs-5.3.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/icu4j-56_1.jar"/>
<classpathentry kind="lib" path="lib/htmllexer.jar"/>
<classpathentry kind="lib" path="lib/jsoup-1.8.3.jar"/>
<classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/>
<classpathentry kind="lib" path="lib/weupnp-0.1.3.jar"/>
<classpathentry kind="lib" path="lib/common-image-3.2.jar"/>
<classpathentry kind="lib" path="lib/common-io-3.2.jar"/>
<classpathentry kind="lib" path="lib/common-lang-3.2.jar"/>
<classpathentry kind="lib" path="lib/imageio-core-3.2.jar"/>
<classpathentry kind="lib" path="lib/imageio-metadata-3.2.jar"/>
<classpathentry kind="lib" path="lib/imageio-tiff-3.2.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="test"/>
<classpathentry excluding="api/|env/|processing/domaingraph/applet/|yacy/|api/bookmarks/|api/ymarks/|api/bookmarks/posts/|api/bookmarks/tags/|api/bookmarks/xbel/|solr/|gsa/|solr/collection1/|api/blacklists/" kind="src" path="htroot"/>
<classpathentry excluding="bookmarks/|ymarks/|bookmarks/posts/|bookmarks/tags/|bookmarks/xbel/|blacklists/" kind="src" path="htroot/api"/>
<classpathentry kind="src" path="htroot/env"/>
<classpathentry kind="src" path="htroot/yacy"/>
<classpathentry excluding="posts/|tags/|xbel/" kind="src" path="htroot/api/bookmarks"/>
<classpathentry kind="src" path="htroot/api/ymarks"/>
<classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
<classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
<classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
<classpathentry kind="src" path="htroot/api/blacklists"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="lib/J7Zip-modified.jar"/>
<classpathentry kind="lib" path="lib/webcat-0.1-swf.jar"/>
<classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
<classpathentry kind="lib" path="lib/jsch-0.1.53.jar"/>
<classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/json-simple-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.10.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="lib/jaudiotagger-2.0.4-20111207.115108-15.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="lib/jcl-over-slf4j-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/log4j-over-slf4j-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.4.jar">
<attributes>
<attribute name="javadoc_location" value="https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/metadata-extractor-2.8.1.jar"/>
<classpathentry kind="lib" path="lib/xmpcore-5.1.2.jar"/>
<classpathentry kind="lib" path="lib/jcifs-1.3.17.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
<classpathentry kind="lib" path="lib/spatial4j-0.4.1.jar"/>
<classpathentry kind="lib" path="lib/zookeeper-3.4.6.jar"/>
<classpathentry kind="lib" path="lib/org.restlet.jar"/>
<classpathentry kind="lib" path="lib/fontbox-1.8.10.jar"/>
<classpathentry kind="lib" path="lib/jempbox-1.8.10.jar"/>
<classpathentry kind="lib" path="lib/pdfbox-1.8.10.jar"/>
<classpathentry kind="lib" path="lib/bcmail-jdk15-1.46.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15-1.46.jar"/>
<classpathentry kind="lib" path="lib/poi-3.13-20150929.jar"/>
<classpathentry kind="lib" path="lib/poi-scratchpad-3.13-20150929.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4.jar">
<attributes>
<attribute name="javadoc_location" value="https://commons.apache.org/proper/commons-io/javadocs/api-release/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.12.jar"/>
<classpathentry kind="lib" path="lib/chardet.jar"/>
<classpathentry kind="lib" path="lib/jetty-client-9.2.13.v20150730.jar">
<attributes>
<attribute name="javadoc_location" value="http://download.eclipse.org/jetty/stable-9/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/jetty-continuation-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-deploy-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-http-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-io-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-jmx-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-proxy-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-security-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-server-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-servlet-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-servlets-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-util-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-webapp-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/jetty-xml-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.5.1.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.5.1.jar"/>
<classpathentry kind="lib" path="lib/noggit-0.6.jar"/>
<classpathentry kind="lib" path="lib/solr-core-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/solr-solrj-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/stax2-api-3.1.4.jar"/>
<classpathentry kind="lib" path="lib/woodstox-core-asl-4.4.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-analyzers-common-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-analyzers-phonetic-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-classification-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-codecs-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-core-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-facet-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-grouping-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-highlighter-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-join-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-memory-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-misc-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-queries-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-queryparser-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-spatial-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-suggest-5.3.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-backward-codecs-5.3.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/icu4j-56_1.jar"/>
<classpathentry kind="lib" path="lib/htmllexer.jar"/>
<classpathentry kind="lib" path="lib/jsoup-1.8.3.jar"/>
<classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/>
<classpathentry kind="lib" path="lib/weupnp-0.1.3.jar"/>
<classpathentry kind="lib" path="lib/common-image-3.2.jar"/>
<classpathentry kind="lib" path="lib/common-io-3.2.jar"/>
<classpathentry kind="lib" path="lib/common-lang-3.2.jar"/>
<classpathentry kind="lib" path="lib/imageio-core-3.2.jar"/>
<classpathentry kind="lib" path="lib/imageio-metadata-3.2.jar"/>
<classpathentry kind="lib" path="lib/imageio-tiff-3.2.jar">
<attributes>
<attribute name="javadoc_location" value="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-tiff/3.2/imageio-tiff-3.2-javadoc.jar"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/imageio-bmp-3.2.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>

@ -182,6 +182,7 @@
<pathelement location="${lib}/httpcore-4.4.4.jar" />
<pathelement location="${lib}/httpmime-4.5.1.jar" />
<pathelement location="${lib}/icu4j-56_1.jar" />
<pathelement location="${lib}/imageio-bmp-3.2.jar" />
<pathelement location="${lib}/imageio-core-3.2.jar" />
<pathelement location="${lib}/imageio-metadata-3.2.jar" />
<pathelement location="${lib}/imageio-tiff-3.2.jar" />

Binary file not shown.

@ -430,6 +430,11 @@
<artifactId>icu4j</artifactId>
<version>56.1</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-bmp</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-tiff</artifactId>

@ -20,82 +20,43 @@
package net.yacy.document;
import java.awt.Container;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.document.parser.images.bmpParser;
import net.yacy.document.parser.images.icoParser;
public class ImageParser {
public static final Image parse(final String filename, final byte[] source) {
final MediaTracker mediaTracker = new MediaTracker(new Container());
Image image = null;
if (((filename.endsWith(".ico")) || (filename.endsWith(".bmp"))) && (bmpParser.isBMP(source))) {
// parse image with BMP parser
image = bmpParser.parse(source).getImage();
if (image == null) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : bmpParser failed for " + filename);
}
return null;
}
} else if ((filename.endsWith(".ico")) && (icoParser.isICO(source))) {
// parse image with ICO parser
icoParser icoparser;
try {
icoparser = new icoParser(source);
image = icoparser.getImage(0);
} catch (final Throwable e) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : could not parse image " + filename, e);
}
}
if (image == null) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : icoParser failed for " + filename);
}
return null;
}
} else {
try {
image = ImageIO.read(new ByteArrayInputStream(source));
} catch(IOException e) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : could not parse image " + filename, e);
}
}
if (image == null) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : ImageIO failed for " + filename);
}
return null;
}
}
if (image == null) {
return null;
}
final int handle = image.hashCode();
mediaTracker.addImage(image, handle);
try {
mediaTracker.waitForID(handle);
if (mediaTracker.isErrorID(handle)) { // true if status ERRORD during loading (happens on not supported formats too)
mediaTracker.removeImage(image, handle);
image = null; // return null to indicate source not handled
}
} catch (final InterruptedException e) {
return null;
}
return image;
}
/**
* @param filename source image file url
* @param source image content as bytes
* @return an Image instance parsed from image content bytes, or null if no parser can handle image format or an error occured
*/
public static final Image parse(final String filename, final byte[] source) {
BufferedImage image = null;
try {
image = ImageIO.read(new ByteArrayInputStream(source));
/*
* With ImageIO.read, image is already loaded as a complete BufferedImage, no need to wait
* full loading with a MediaTracker
*/
} catch (IOException e) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : could not parse image " + filename, e);
}
}
if (image == null) {
if (ConcurrentLog.isFine("IMAGEPARSER")) {
ConcurrentLog.fine("IMAGEPARSER", "IMAGEPARSER.parse : ImageIO failed for " + filename);
}
return null;
}
return image;
}
}

@ -32,8 +32,17 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import com.twelvemonkeys.imageio.plugins.bmp.BMPImageReader;
import net.yacy.cora.util.ConcurrentLog;
/**
*
* @deprecated use ImageIO {@link BMPImageReader} from github.com/haraldk/TwelveMonkeys
* library (imageio-bmp-3.2.jar), which as better BMP format
* variants support
*/
@Deprecated
public class bmpParser {
// this is a implementation of http://de.wikipedia.org/wiki/Windows_Bitmap

@ -46,6 +46,13 @@ import java.util.Set;
import javax.imageio.ImageIO;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.lang.GeoLocation;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.Tag;
import com.drew.metadata.exif.GpsDirectory;
import net.yacy.cora.document.id.AnchorURL;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.document.id.MultiProtocolURL;
@ -55,16 +62,8 @@ import net.yacy.document.Document;
import net.yacy.document.Parser;
import net.yacy.document.VocabularyScraper;
import net.yacy.document.parser.html.ImageEntry;
import net.yacy.document.parser.images.bmpParser.IMAGEMAP;
import net.yacy.kelondro.util.FileUtils;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.lang.GeoLocation;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.Tag;
import com.drew.metadata.exif.GpsDirectory;
/**
* Parser for images, bmp and jpeg and all supported by the Java Image I/O API
* by default java ImageIO supports bmp, gif, jpg, jpeg, png, wbmp (tif if jai-imageio is in classpath/registered)
@ -75,11 +74,9 @@ public class genericImageParser extends AbstractParser implements Parser {
public genericImageParser() {
super("Generic Image Parser");
SUPPORTED_EXTENSIONS.add("bmp");
SUPPORTED_EXTENSIONS.add("jpe"); // not listed in ImageIO extension but sometimes uses for jpeg
SUPPORTED_EXTENSIONS.addAll(Arrays.asList(ImageIO.getReaderFileSuffixes()));
SUPPORTED_MIME_TYPES.add("image/bmp");
SUPPORTED_MIME_TYPES.add("image/jpg"); // this is in fact a 'wrong' mime type. We leave it here because that is a common error that occurs in the internet frequently
SUPPORTED_MIME_TYPES.addAll(Arrays.asList(ImageIO.getReaderMIMETypes()));
}
@ -102,21 +99,7 @@ public class genericImageParser extends AbstractParser implements Parser {
String ext = MultiProtocolURL.getFileExtension(filename);
double gpslat = 0;
double gpslon = 0;
if (mimeType.equals("image/bmp") || ext.equals("bmp")) {
byte[] b;
try {
b = FileUtils.read(source);
} catch (final IOException e) {
ConcurrentLog.logException(e);
throw new Parser.Failure(e.getMessage(), location);
}
if (bmpParser.isBMP(b)) {
final IMAGEMAP imap = bmpParser.parse(b);
ii = parseJavaImage(location, imap.getImage());
} else {
throw new Parser.Failure("Not supported by bmpParser", location);
}
} else if (mimeType.equals("image/jpeg") || ext.equals("jpg") || ext.equals("jpeg") || ext.equals("jpe")) {
if (mimeType.equals("image/jpeg") || ext.equals("jpg") || ext.equals("jpeg") || ext.equals("jpe")) {
// use the exif parser from
// http://www.drewnoakes.com/drewnoakes.com/code/exif/
// javadoc is at: http://www.drewnoakes.com/drewnoakes.com/code/exif/javadoc/

@ -32,9 +32,17 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import net.yacy.cora.util.ConcurrentLog;
import com.twelvemonkeys.imageio.plugins.bmp.ICOImageReader;
import net.yacy.cora.util.ConcurrentLog;
/**
*
* @deprecated use ImageIO {@link ICOImageReader} from github.com/haraldk/TwelveMonkeys
* library (imageio-bmp-3.2.jar), which as better BMP format
* variants support, and support PNG encoded icons.
*/
@Deprecated
public class icoParser {
// this is a implementation of http://msdn2.microsoft.com/en-us/library/ms997538(d=printer).aspx

Loading…
Cancel
Save