use of digilib.util.ImageSize in project digilib by robcast.
the class ImageLoaderDocuImage method identify.
/*
* Check image size and type and store in ImageInput
* @see digilib.image.ImageInfoDocuImage#identify(digilib.io.ImageInput)
*/
public ImageInput identify(ImageInput input) throws IOException {
ImageInput ii = null;
if (!reuseReader) {
// try parent method first
ii = super.identify(input);
if (ii != null) {
return ii;
}
}
logger.debug("identifying (ImageIO) " + input);
try {
/*
* try ImageReader
*/
reader = getReader(input);
// set size
ImageSize d = new ImageSize(reader.getWidth(0), reader.getHeight(0));
input.setSize(d);
// set mime type
if (input.getMimetype() == null) {
if (input.hasFile()) {
String t = FileOps.mimeForFile(input.getFile());
input.setMimetype(t);
} else {
// FIXME: is format name a mime type???
String t = reader.getFormatName();
input.setMimetype(t);
}
}
return input;
} catch (FileOpException e) {
// maybe just our class doesn't know what to do
logger.error("ImageLoaderDocuimage unable to identify: " + e);
return null;
} finally {
if (!reuseReader && reader != null) {
reader.dispose();
}
}
}
use of digilib.util.ImageSize in project digilib by robcast.
the class BioFormatsDocuImage method identify.
/*
* (non-Javadoc)
*
* @see digilib.image.DocuImageImpl#identify(digilib.io.ImageInput)
*/
@Override
public ImageInput identify(ImageInput ii) throws IOException {
ImageReader reader = new ImageReader();
try {
reader.setId(ii.getFile().getAbsolutePath());
} catch (FormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int width = reader.getSizeX();
int height = reader.getSizeY();
String fmt = reader.getFormat();
String mt = "";
if (fmt.equalsIgnoreCase("Tagged Image File Format")) {
mt = "image/tiff";
} else if (fmt.equalsIgnoreCase("JPEG")) {
mt = "image/jpeg";
}
logger.debug("BioFormats identify: width=" + width + " height=" + height + " format=" + fmt + " mimetype=" + mt);
ii.setSize(new ImageSize(width, height));
ii.setMimetype(mt);
return ii;
}
use of digilib.util.ImageSize in project digilib by robcast.
the class ImageJ1DocuImage method identify.
/* Check image size and type and store in ImageInput */
public ImageInput identify(ImageInput input) throws IOException {
// try parent method first
ImageInput ii = super.identify(input);
if (ii != null) {
return ii;
}
logger.debug("identifying (ImageJ1) " + input);
String path = input.getFile().getAbsolutePath();
img = IJ.openImage(path);
// set size
ImageSize d = new ImageSize(img.getWidth(), img.getHeight());
input.setSize(d);
// set mime type
if (input.getMimetype() == null) {
String t = FileOps.mimeForFile(input.getFile());
input.setMimetype(t);
}
return input;
}
use of digilib.util.ImageSize in project digilib by robcast.
the class JAIDocuImage method getSize.
/* returns the current image size
* @see digilib.image.DocuImageImpl#getSize()
*/
public ImageSize getSize() {
ImageSize is = null;
// TODO: do we want to cache imgSize?
int h = 0;
int w = 0;
if (img != null) {
// get size from image
h = img.getHeight();
w = img.getWidth();
is = new ImageSize(w, h);
}
return is;
}
use of digilib.util.ImageSize in project digilib by robcast.
the class JAIImageLoaderDocuImage method getSize.
/* returns the size of the current image */
public ImageSize getSize() {
ImageSize is = null;
// TODO: can we cache imageSize?
int h = 0;
int w = 0;
try {
if (img == null) {
// get size from ImageReader
h = reader.getHeight(0);
w = reader.getWidth(0);
} else {
// get size from image
h = img.getHeight();
w = img.getWidth();
}
is = new ImageSize(w, h);
} catch (IOException e) {
logger.debug("error in getSize:", e);
}
return is;
}
Aggregations