Search in sources :

Example 6 with ImageSize

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();
        }
    }
}
Also used : ImageInput(digilib.io.ImageInput) ImageSize(digilib.util.ImageSize) FileOpException(digilib.io.FileOpException)

Example 7 with ImageSize

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;
}
Also used : ImageSize(digilib.util.ImageSize) ImageReader(loci.formats.ImageReader) BufferedImageReader(loci.formats.gui.BufferedImageReader) FormatException(loci.formats.FormatException)

Example 8 with ImageSize

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;
}
Also used : ImageInput(digilib.io.ImageInput) ImageSize(digilib.util.ImageSize)

Example 9 with ImageSize

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;
}
Also used : ImageSize(digilib.util.ImageSize)

Example 10 with ImageSize

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;
}
Also used : ImageSize(digilib.util.ImageSize) IOException(java.io.IOException)

Aggregations

ImageSize (digilib.util.ImageSize)18 ImageInput (digilib.io.ImageInput)6 IOException (java.io.IOException)5 FileOpException (digilib.io.FileOpException)3 ImageSet (digilib.io.ImageSet)2 DocuDirectory (digilib.io.DocuDirectory)1 DocuDirent (digilib.io.DocuDirent)1 ImageFileSet (digilib.io.ImageFileSet)1 Rectangle2D (java.awt.geom.Rectangle2D)1 RandomAccessFile (java.io.RandomAccessFile)1 JsonGenerator (javax.json.stream.JsonGenerator)1 RenderedOp (javax.media.jai.RenderedOp)1 ServletException (javax.servlet.ServletException)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 FormatException (loci.formats.FormatException)1 ImageReader (loci.formats.ImageReader)1 BufferedImageReader (loci.formats.gui.BufferedImageReader)1 ImageInfo (org.devlib.schmidt.imageinfo.ImageInfo)1