[ImageJ-devel] opening a tif file from a resource
Rasband, Wayne (NIH/NIMH) [E]
rasbandw at mail.nih.gov
Wed Jan 16 23:42:34 CST 2013
On Jan 16, 2013, at 12:50 AM, Chris wrote:
> I can open a jpeg file using
>
> java.net.URL url;
> url = getClass().getResource(image.jpg);
> java.awt.Image image = Toolkit.getDefaultToolkit().getImage(url);
> imp = new ImagePlus("", image);
> if (imp != null) {
> imp.show();
> }
>
> but this will not work for a tiff image. My tiff image is a stack. How can I open the tiff stack that is bundled in the resources folder of my jar file?
Hi Chris,
The "JAR Resources Demo" plugin at
http://rsbweb.nih.gov/ij/plugins/pcl-demo.html
opens TIFFs using
InputStream is = getClass().getResourceAsStream(path+"image.tif");
if (is!=null) {
Opener opener = new Opener();
ImagePlus imp = opener.openTiff(is, "San Francisco (TIFF)");
if (imp!=null)
imp.show();
}
which should work with ImageJ TIFF stacks.
-wayne
More information about the ImageJ-devel
mailing list