Minimalistic setup:
Win7x64, Eclipse Oxygen.3 Release (4.7.3), JDK 1.8.0_162, bio-formats library https://downloads.openmicroscopy.org/bi ... ackage.jar
Code:
- Code: Select all
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import loci.formats.FormatException;
import loci.formats.ImageReader;
import loci.formats.gui.BufferedImageReader;
public class TestReader {
public static void main(String[] args) throws FormatException, IOException {
ImageReader tr = new ImageReader();
tr.setId("D:/tmp/SESSION4_Image2.tif");
BufferedImageReader bir = new BufferedImageReader(tr);
BufferedImage bi = bir.openImage(0, 5000, 5000, 512, 512);
File outputfile = new File("saved.png");
ImageIO.write(bi, "png", outputfile);
bir.close();
}
}
Output (note "nice" SlideBook6 exceptions btw):
- Code: Select all
18:23:39.620 [main] DEBUG loci.formats.ClassList - Could not find loci.formats.in.SlideBook6Reader
java.lang.ClassNotFoundException: loci.formats.in.SlideBook6Reader
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_162]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_162]
at java.lang.Class.forName(Class.java:264) ~[na:1.8.0_162]
at loci.formats.ClassList.parseLine(ClassList.java:196) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ClassList.parseFile(ClassList.java:258) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ClassList.<init>(ClassList.java:138) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ClassList.<init>(ClassList.java:122) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ImageReader.getDefaultReaderClasses(ImageReader.java:79) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ImageReader.<init>(ImageReader.java:116) [bioformats_package-5.8.2.jar:5.8.2]
at TestReader.main(TestReader.java:13) [bin/:na]
18:23:39.636 [main] DEBUG loci.formats.ClassList - Could not find loci.formats.in.ScreenReader
java.lang.ClassNotFoundException: loci.formats.in.ScreenReader
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_162]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_162]
at java.lang.Class.forName(Class.java:264) ~[na:1.8.0_162]
at loci.formats.ClassList.parseLine(ClassList.java:196) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ClassList.parseFile(ClassList.java:258) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ClassList.<init>(ClassList.java:138) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ClassList.<init>(ClassList.java:122) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ImageReader.getDefaultReaderClasses(ImageReader.java:79) [bioformats_package-5.8.2.jar:5.8.2]
at loci.formats.ImageReader.<init>(ImageReader.java:116) [bioformats_package-5.8.2.jar:5.8.2]
at TestReader.main(TestReader.java:13) [bin/:na]
18:23:39.854 [main] DEBUG o.s.nativelib.NativeLibraryUtil - processor is INTEL_64 os.arch is amd64
18:23:39.854 [main] DEBUG o.s.nativelib.NativeLibraryUtil - architecture is WINDOWS_64 os.name is windows 7
18:23:39.854 [main] DEBUG o.s.nativelib.NativeLibraryUtil - architecture is WINDOWS_64 os.name is windows 7
18:23:39.854 [main] DEBUG o.s.nativelib.NativeLibraryUtil - platform specific path is META-INF/lib/windows_64/
18:23:39.854 [main] DEBUG o.scijava.nativelib.BaseJniExtractor - mappedLib is turbojpeg.dll
18:23:39.854 [main] DEBUG o.scijava.nativelib.BaseJniExtractor - URL is jar:file:/D:/JavaLibs/bioformats_package-5.8.2.jar!/META-INF/lib/windows_64/turbojpeg.dll
18:23:39.854 [main] DEBUG o.scijava.nativelib.BaseJniExtractor - URL path is file:/D:/JavaLibs/bioformats_package-5.8.2.jar!/META-INF/lib/windows_64/turbojpeg.dll
18:23:39.901 [main] DEBUG o.scijava.nativelib.BaseJniExtractor - Extracting 'jar:file:/D:/JavaLibs/bioformats_package-5.8.2.jar!/META-INF/lib/windows_64/turbojpeg.dll' to 'C:\Users\xxx\AppData\Local\Temp\turbojpeg4206970963713207425.dll'
18:23:39.948 [main] DEBUG loci.common.NIOByteBufferProvider - Using mapped byte buffer? false
18:23:39.995 [main] INFO loci.formats.ImageReader - TiffDelegateReader initializing D:/tmp/SESSION4_Image2.tif
18:23:39.995 [main] DEBUG loci.formats.FormatHandler - TiffReader initializing D:/tmp/SESSION4_Image2.tif
18:23:39.995 [main] DEBUG loci.formats.FormatHandler - loci.formats.in.TiffReader.initFile(D:/tmp/SESSION4_Image2.tif)
18:23:39.995 [main] INFO loci.formats.in.MinimalTiffReader - Reading IFDs
18:23:39.995 [main] INFO loci.formats.in.MinimalTiffReader - Populating metadata
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Loaded properties from: services.properties
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.POIService and implementation class loci.formats.services.POIServiceImpl
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.MDBService and implementation class loci.formats.services.MDBServiceImpl
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.JPEGTurboService and implementation class loci.formats.services.JPEGTurboServiceImpl
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface ome.codecs.services.LuraWaveService and implementation class ome.codecs.services.LuraWaveServiceImpl
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.JAIIIOService and implementation class loci.formats.services.JAIIIOServiceImpl
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.WlzService and implementation class loci.formats.services.WlzServiceImpl
18:23:40.010 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.JHDFService and implementation class loci.formats.services.JHDFServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.NetCDFService and implementation class loci.formats.services.NetCDFServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.EXIFService and implementation class loci.formats.services.EXIFServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.MetakitService and implementation class loci.formats.services.MetakitServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.LuraWaveService and implementation class loci.formats.services.LuraWaveServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.OMEXMLService and implementation class loci.formats.services.OMEXMLServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface ome.codecs.services.JAIIIOService and implementation class ome.codecs.services.JAIIIOServiceImpl
18:23:40.026 [main] DEBUG loci.common.services.ServiceFactory - Added interface interface loci.formats.services.JPEGXRService and implementation class loci.formats.services.JPEGXRServiceImpl
18:23:40.026 [main] INFO loci.formats.in.TiffReader - Checking comment style
18:23:40.026 [main] INFO loci.formats.in.BaseTiffReader - Populating OME metadata
18:23:40.041 [main] DEBUG loci.formats.tiff.TiffParser - Reading tile Length 147566 Offset 8364333
18:23:40.166 [main] DEBUG loci.common.Location - Location.mapFile: embedded-stream.raw -> null
18:23:40.166 [main] DEBUG loci.common.Location - Location.mapFile: embedded-stream.raw -> null
Input TIFF file:
http://folk.uio.no/dmitrd/bio-formats-5.8.2/SESSION4_Image2.tif
Open in Windows Photo Viewer:
Result:
It can be anything but black