comparison servlet/src/digilib/image/ImageInfoDocuImage.java @ 564:4c51d71aef13 digilibPDF

more reshuffling of classes
author robcast
date Fri, 17 Dec 2010 22:03:14 +0100
parents
children 50f291d808b1
comparison
equal deleted inserted replaced
563:686086d6e6d6 564:4c51d71aef13
1 /**
2 *
3 */
4 package digilib.image;
5
6 import java.io.File;
7 import java.io.IOException;
8 import java.io.RandomAccessFile;
9
10 import org.marcoschmidt.image.ImageInfo;
11
12 import digilib.io.ImageFile;
13
14 /** Simple abstract implementation of the <code>DocuImage</code> interface.
15 * Implements only the identify method using the ImageInfo class.
16 * @author casties
17 *
18 */
19 public abstract class ImageInfoDocuImage extends DocuImageImpl {
20
21 /** Check image size and type and store in ImageFile f */
22 public ImageFile identify(ImageFile imgf) throws IOException {
23 // fileset to store the information
24 File f = imgf.getFile();
25 if (f == null) {
26 throw new IOException("File not found!");
27 }
28 RandomAccessFile raf = new RandomAccessFile(f, "r");
29 // set up ImageInfo object
30 ImageInfo iif = new ImageInfo();
31 iif.setInput(raf);
32 iif.setCollectComments(false);
33 iif.setDetermineImageNumber(false);
34 logger.debug("identifying (ImageInfo) " + f);
35 // try with ImageInfo first
36 if (iif.check()) {
37 ImageSize d = new ImageSize(iif.getWidth(), iif.getHeight());
38 imgf.setSize(d);
39 imgf.setMimetype(iif.getMimeType());
40 //logger.debug(" format:"+iif.getFormatName());
41 raf.close();
42 logger.debug("image size: " + imgf.getSize());
43 return imgf;
44 } else {
45 raf.close();
46 }
47 return null;
48 }
49
50
51 }