339
|
1 /* ImageFile.java -- digilib image file class.
|
|
2
|
|
3 Digital Image Library servlet components
|
|
4
|
|
5 Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
|
|
6
|
|
7 This program is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2 of the License, or (at your
|
|
10 option) any later version.
|
|
11
|
|
12 Please read license.txt for the full details. A copy of the GPL
|
|
13 may be found at http://www.gnu.org/copyleft/lgpl.html
|
|
14
|
|
15 You should have received a copy of the GNU General Public License
|
|
16 along with this program; if not, write to the Free Software
|
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
|
19 * Created on 25.02.2003
|
|
20 */
|
|
21
|
|
22 package digilib.io;
|
|
23
|
|
24 import java.io.File;
|
|
25 import java.io.IOException;
|
|
26
|
|
27 import digilib.image.ImageOps;
|
|
28 import digilib.image.ImageSize;
|
|
29
|
|
30 /**
|
|
31 * @author casties
|
|
32 */
|
|
33 public class ImageFile extends File {
|
|
34
|
|
35 private static final long serialVersionUID = 1L;
|
|
36
|
|
37 /** file mime-type */
|
|
38 private String mimetype = null;
|
|
39
|
|
40 /** image size in pixels */
|
|
41 private ImageSize pixelSize = null;
|
|
42
|
|
43 /**
|
|
44 * @param pathname
|
|
45 */
|
|
46 public ImageFile(String pathname) {
|
|
47 super(pathname);
|
|
48 }
|
|
49
|
|
50 /**
|
|
51 * @param file
|
|
52 */
|
|
53 public ImageFile(File file) {
|
|
54 super(file.getPath());
|
|
55 }
|
|
56
|
|
57 /**
|
|
58 * @return ImageSize
|
|
59 */
|
|
60 public ImageSize getSize() {
|
|
61 return pixelSize;
|
|
62 }
|
|
63
|
|
64 /**
|
|
65 * Sets the imageSize.
|
|
66 * @param imageSize The imageSize to set
|
|
67 */
|
|
68 public void setSize(ImageSize imageSize) {
|
|
69 this.pixelSize = imageSize;
|
|
70 }
|
|
71
|
|
72 /**
|
|
73 * @return String
|
|
74 */
|
|
75 public String getMimetype() {
|
|
76 return mimetype;
|
|
77 }
|
|
78
|
|
79 /**
|
|
80 * Sets the mimetype.
|
|
81 * @param mimetype The mimetype to set
|
|
82 */
|
|
83 public void setMimetype(String filetype) {
|
|
84 this.mimetype = filetype;
|
|
85 }
|
|
86
|
|
87 /**
|
|
88 * Checks image size.
|
|
89 * @throws IOException
|
|
90 *
|
|
91 */
|
|
92 public void check() throws IOException {
|
|
93 if (pixelSize != null) {
|
|
94 return;
|
|
95 }
|
|
96 ImageOps.checkFile(this);
|
|
97 }
|
|
98
|
|
99 }
|