Example usage for org.apache.commons.imaging ImageInfo getFormatName

List of usage examples for org.apache.commons.imaging ImageInfo getFormatName

Introduction

In this page you can find the example usage for org.apache.commons.imaging ImageInfo getFormatName.

Prototype

public String getFormatName() 

Source Link

Document

Returns a string with the name of the image file format.

Usage

From source file:com.vividsolutions.jump.workbench.imagery.graphic.CommonsImage.java

protected void initImage() throws ReferencedImageException {
    BufferedImage image = getImage();
    if (image != null)
        return;/*from ww w . j  a  va2 s . c om*/

    String uri = getUri();
    try {
        is = CompressedFile.openFile(uri);
        ImageInfo info = Imaging.getImageInfo(is,
                UriUtil.getFileName(CompressedFile.getTargetFileWithPath(new URI(uri))));
        type = info.getFormatName();
        close(is);
        is = CompressedFile.openFile(uri);
        image = Imaging.getBufferedImage(is);
        close(is);
        setImage(image);
    } catch (Exception e) {
        throw new ReferencedImageException(e);
    } finally {
        close(is);
    }
}