Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
Image: some more logging during IIOServiceProvider registering
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlep committed Apr 4, 2018
1 parent bf687c0 commit 7216778
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/main/java/eu/transkribus/interfaces/types/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.spi.IIORegistry;
import javax.imageio.spi.ImageReaderWriterSpi;

import org.opencv.core.Mat;
import org.slf4j.Logger;
Expand Down Expand Up @@ -224,14 +225,24 @@ public static void registerImageIOServices() {
IIORegistry registry = IIORegistry.getDefaultInstance();

// have to programmatically register tiff reader / writer in tomcat
registry.registerServiceProvider(new TIFFImageWriterSpi(), javax.imageio.spi.ImageWriterSpi.class);
registry.registerServiceProvider(new TIFFImageReaderSpi(), javax.imageio.spi.ImageReaderSpi.class);
registerImageIOService(registry, new TIFFImageWriterSpi(), javax.imageio.spi.ImageWriterSpi.class);
registerImageIOService(registry, new TIFFImageReaderSpi(), javax.imageio.spi.ImageReaderSpi.class);

registry.registerServiceProvider(new com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriterSpi(),
registerImageIOService(registry, new com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriterSpi(),
javax.imageio.spi.ImageWriterSpi.class);
registry.registerServiceProvider(new com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReaderSpi(),
javax.imageio.spi.ImageReaderSpi.class);

registerImageIOService(registry, new com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReaderSpi(),
javax.imageio.spi.ImageReaderSpi.class);
}

private static <T extends ImageReaderWriterSpi> void registerImageIOService(IIORegistry registry, T provider, Class<T> clazz) {
if(registry == null || provider == null || clazz == null) {
throw new IllegalArgumentException("An argument is null!");
}
if(registry.registerServiceProvider(provider, clazz)) {
logger.info("Registered IIOServiceProvider: " + provider.getPluginClassName());
} else {
logger.info("Ignoring already registered IIOServiceProvider: " + provider.getPluginClassName());
}
}

public static void testReaders() throws IOException {
Expand Down

0 comments on commit 7216778

Please sign in to comment.