Java Utililty Methods ImageIO Usage

List of utility methods to do ImageIO Usage

Description

The list of methods to do ImageIO Usage are organized into topic(s).

Method

voidcloseEL(ImageInputStream iis)
close EL
try {
    if (iis != null)
        iis.close();
} catch (Throwable t) {
IIOMetadataNodecreateAsciiField(int number, String name, String val)
create Ascii Field
IIOMetadataNode field, arrayNode, valueNode;
field = new IIOMetadataNode("TIFFField");
field.setAttribute("number", Integer.toString(number));
field.setAttribute("name", name);
arrayNode = new IIOMetadataNode("TIFFAsciis");
field.appendChild(arrayNode);
valueNode = new IIOMetadataNode("TIFFAscii");
arrayNode.appendChild(valueNode);
...
ImageWriteParamcreateImageWriteParam(ImageWriter writer, float quality)
create Image Write Param
ImageWriteParam param = writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(quality);
return param;
voidderegisterProvider(final ServiceRegistry registry, final IIOServiceProvider provider, final Class category)
THIS METHOD WILL ME MOVED/RENAMED, DO NOT USE.
registry.deregisterServiceProvider(category.cast(provider), category);
ImageWriteParamgetParams(ImageWriter writer)
get Params
ImageWriteParam param = writer.getDefaultWriteParam();
try {
    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    param.setCompressionQuality(1.0f);
} catch (Throwable ignored) {
return param;
intguessCompressionRatio(final ImageReaderWriterSpi spi)
Guesses the compression ratio for the given image format.
if (spi != null) {
    for (final String format : spi.getFormatNames()) {
        if (format.equalsIgnoreCase("png")) {
            return 4;
        if (format.equalsIgnoreCase("jpeg")) {
            return 8;
        if (format.equalsIgnoreCase("tiff")) {
            return 1;
        if (format.equalsIgnoreCase("bmp") || format.equalsIgnoreCase("raw")) {
            return 1;
return 0;
TlookupProviderByName(final ServiceRegistry registry, final String providerClassName)
THIS METHOD WILL ME MOVED/RENAMED, DO NOT USE.
try {
    return (T) registry.getServiceProviderByClass(Class.forName(providerClassName));
} catch (ClassNotFoundException ignore) {
    return null;
voidsetCompressionQuality(ImageWriteParam params, int quality)
set Compression Quality
if (quality <= 0) {
    quality = 1;
if (quality > 100) {
    quality = 100;
try {
    params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
...