Mercurial > hg > digilib-old
comparison servlet/src/digilib/image/ImageInfoDocuImage.java @ 588:aee436f0549d stream
more work on stream input
author | robcast |
---|---|
date | Thu, 06 Jan 2011 14:37:50 +0100 |
parents | 50f291d808b1 |
children | 69bc69381ac4 |
comparison
equal
deleted
inserted
replaced
587:720d061a1b30 | 588:aee436f0549d |
---|---|
7 import java.io.IOException; | 7 import java.io.IOException; |
8 import java.io.RandomAccessFile; | 8 import java.io.RandomAccessFile; |
9 | 9 |
10 import org.marcoschmidt.image.ImageInfo; | 10 import org.marcoschmidt.image.ImageInfo; |
11 | 11 |
12 import digilib.io.ImageFile; | |
13 import digilib.io.ImageInput; | 12 import digilib.io.ImageInput; |
14 | 13 |
15 /** Simple abstract implementation of the <code>DocuImage</code> interface. | 14 /** Simple abstract implementation of the <code>DocuImage</code> interface. |
16 * Implements only the identify method using the ImageInfo class. | 15 * Implements only the identify method using the ImageInfo class. |
17 * @author casties | 16 * @author casties |
18 * | 17 * |
19 */ | 18 */ |
20 public abstract class ImageInfoDocuImage extends DocuImageImpl { | 19 public abstract class ImageInfoDocuImage extends DocuImageImpl { |
21 | 20 |
22 /** Check image size and type and store in ImageFile f */ | 21 /** Check image size and type and store in ImageFile f */ |
23 public ImageInput identify(ImageFile imgf) throws IOException { | 22 public ImageInput identify(ImageInput ii) throws IOException { |
24 // fileset to store the information | 23 // fileset to store the information |
25 File f = imgf.getFile(); | 24 File f = ii.getFile(); |
26 if (f == null) { | 25 if (f == null) { |
27 throw new IOException("File not found!"); | 26 throw new IOException("File not found!"); |
28 } | 27 } |
29 RandomAccessFile raf = new RandomAccessFile(f, "r"); | 28 RandomAccessFile raf = new RandomAccessFile(f, "r"); |
30 // set up ImageInfo object | 29 // set up ImageInfo object |
34 iif.setDetermineImageNumber(false); | 33 iif.setDetermineImageNumber(false); |
35 logger.debug("identifying (ImageInfo) " + f); | 34 logger.debug("identifying (ImageInfo) " + f); |
36 // try with ImageInfo first | 35 // try with ImageInfo first |
37 if (iif.check()) { | 36 if (iif.check()) { |
38 ImageSize d = new ImageSize(iif.getWidth(), iif.getHeight()); | 37 ImageSize d = new ImageSize(iif.getWidth(), iif.getHeight()); |
39 imgf.setSize(d); | 38 ii.setSize(d); |
40 imgf.setMimetype(iif.getMimeType()); | 39 ii.setMimetype(iif.getMimeType()); |
41 //logger.debug(" format:"+iif.getFormatName()); | 40 //logger.debug(" format:"+iif.getFormatName()); |
42 raf.close(); | 41 raf.close(); |
43 logger.debug("image size: " + imgf.getSize()); | 42 logger.debug("image size: " + ii.getSize()); |
44 return imgf; | 43 return ii; |
45 } else { | 44 } else { |
46 raf.close(); | 45 raf.close(); |
47 } | 46 } |
48 return null; | 47 return null; |
49 } | 48 } |