Mercurial > hg > digilib-old
view servlet/src/digilib/image/ImageInfoDocuImage.java @ 787:b322f553f92e jquery
more new plugin architecture.
author | robcast |
---|---|
date | Thu, 17 Feb 2011 22:36:49 +0100 |
parents | 4c51d71aef13 |
children | 50f291d808b1 |
line wrap: on
line source
/** * */ package digilib.image; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import org.marcoschmidt.image.ImageInfo; import digilib.io.ImageFile; /** Simple abstract implementation of the <code>DocuImage</code> interface. * Implements only the identify method using the ImageInfo class. * @author casties * */ public abstract class ImageInfoDocuImage extends DocuImageImpl { /** Check image size and type and store in ImageFile f */ public ImageFile identify(ImageFile imgf) throws IOException { // fileset to store the information File f = imgf.getFile(); if (f == null) { throw new IOException("File not found!"); } RandomAccessFile raf = new RandomAccessFile(f, "r"); // set up ImageInfo object ImageInfo iif = new ImageInfo(); iif.setInput(raf); iif.setCollectComments(false); iif.setDetermineImageNumber(false); logger.debug("identifying (ImageInfo) " + f); // try with ImageInfo first if (iif.check()) { ImageSize d = new ImageSize(iif.getWidth(), iif.getHeight()); imgf.setSize(d); imgf.setMimetype(iif.getMimeType()); //logger.debug(" format:"+iif.getFormatName()); raf.close(); logger.debug("image size: " + imgf.getSize()); return imgf; } else { raf.close(); } return null; } }