Mercurial > hg > digilib-old
changeset 277:0794fa8d594a
Servlet version 1.22b1
- more fast searching (hopefully all working now)
- some simple synchronisation
- some reshuffling of methods to eliminate cruft
author | robcast |
---|---|
date | Fri, 15 Oct 2004 16:59:47 +0200 |
parents | 0fa87ab00feb |
children | d5fe845db95f |
files | servlet/src/digilib/image/DocuInfo.java servlet/src/digilib/image/ImageLoaderDocuInfo.java servlet/src/digilib/image/ImageLoaderImageInfoDocuInfo.java |
diffstat | 3 files changed, 0 insertions(+), 198 deletions(-) [+] |
line wrap: on
line diff
--- a/servlet/src/digilib/image/DocuInfo.java Tue Oct 12 16:08:47 2004 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* DocuInfo -- General image information interface - - Digital Image Library servlet components - - Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - Please read license.txt for the full details. A copy of the GPL - may be found at http://www.gnu.org/copyleft/lgpl.html - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -package digilib.image; - -import java.io.IOException; - -import digilib.io.ImageFile; - -/** - * @author casties - * - */ -public interface DocuInfo { - - /** Checks the size and type of the ImageFile f. - * - * The image size and type of the ImageFile f is determined and stored in - * the ImageFile object. Returns true if successfull. - * - * @param f ImageFile to be checked. - * @return boolean true if check was successfull. - * @throws FileOpException Exception thrown on error. - */ - public boolean checkFile(ImageFile f) throws IOException; - -}
--- a/servlet/src/digilib/image/ImageLoaderDocuInfo.java Tue Oct 12 16:08:47 2004 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* ImageLoaderDocuInfo -- DocuInfo implementation using ImageLoader API - - Digital Image Library servlet components - - Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - Please read license.txt for the full details. A copy of the GPL - may be found at http://www.gnu.org/copyleft/lgpl.html - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Created on 11.06.2003 - */ - -package digilib.image; - -import java.io.IOException; - -import digilib.io.ImageFile; -import digilib.io.FileOps; - -/** - * @author casties - * - */ -public class ImageLoaderDocuInfo implements DocuInfo { - - private ImageLoaderDocuImage img = new ImageLoaderDocuImage(); - - /* check image size and type and store in ImageFile f */ - public boolean checkFile(ImageFile f) throws IOException { - ImageLoaderDocuImage img = new ImageLoaderDocuImage(); - img.preloadImage(f); - img.reader = img.reader; - ImageSize d = - new ImageSize(img.reader.getWidth(0), img.reader.getHeight(0)); - f.setSize(d); - String t = img.reader.getFormatName(); - t = FileOps.mimeForFile(f.getFile()); - f.setMimetype(t); - // clean up - //img.reader.reset(); - //img.reader = null; - return true; - } - -}
--- a/servlet/src/digilib/image/ImageLoaderImageInfoDocuInfo.java Tue Oct 12 16:08:47 2004 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * ImageLoaderImageInfoDocuInfo -- DocuInfo implementation using ImageInfo and - * ImageLoader API - * - * Digital Image Library servlet components - * - * Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Please read license.txt for the full details. A copy of the GPL may be found - * at http://www.gnu.org/copyleft/lgpl.html - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on 11.06.2003 - */ -package digilib.image; -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.Iterator; -import javax.imageio.ImageIO; -import javax.imageio.ImageReader; -import javax.imageio.stream.ImageInputStream; -import org.apache.log4j.Logger; -import org.marcoschmidt.image.ImageInfo; -import digilib.io.FileOpException; -import digilib.io.FileOps; -import digilib.io.ImageFile; -import digilib.io.ImageFileset; -/** - * @author casties - * - */ -public class ImageLoaderImageInfoDocuInfo implements DocuInfo { - private Logger logger = Logger.getLogger(this.getClass()); - /* check image size and type and store in ImageFile f */ - public boolean checkFile(ImageFile imgf) throws IOException { - // fileset to store the information - ImageFileset imgfs = imgf.getParent(); - 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()); - if (imgfs != null) { - imgfs.setAspect(d); - } - raf.close(); - } else { - logger.debug("identifying (ImageIO) " + f); - /* - * else use ImageReader - */ - ImageInputStream istream = ImageIO.createImageInputStream(raf); - Iterator readers = ImageIO.getImageReaders(istream); - if ((readers == null) || (!readers.hasNext())) { - throw new FileOpException("ERROR: unknown image file format!"); - } - ImageReader reader = (ImageReader) readers.next(); - /* are there more readers? */ - logger.debug("ImageIO: this reader: " + reader.getClass()); - while (readers.hasNext()) { - logger.debug("ImageIO: next reader: " - + readers.next().getClass()); - } - reader.setInput(istream); - ImageSize d = new ImageSize(reader.getWidth(0), reader.getHeight(0)); - imgf.setSize(d); - String t = reader.getFormatName(); - t = FileOps.mimeForFile(f); - imgf.setMimetype(t); - if (imgfs != null) { - imgfs.setAspect(d); - } - // dispose the reader to free resources - reader.dispose(); - raf.close(); - } - logger.debug("image size: " + imgf.getSize()); - return true; - } -} \ No newline at end of file