Skip to main content

IIO Progress Listener with TIFF files

4 replies [Last post]
kading
Offline
Joined: 2003-11-24
Points: 0

Hello everyone. Do the TIFF reader in Java image I/O not update the IIOReadProgressListeners? The method 'imageProgress' only gets called twice, at 0% and at 100% done. My application is intented to load large TIFF images (40-200MB) over a fairly slow local area network. It is important that users get a progress indicator.

Anyone know what is going on and even more importantly how to get it to work? Thanks in advance for any help! :)

Florian Kading

A test application showing the problem:

<br />
import java.awt.image.*;<br />
import java.io.*;<br />
import java.util.*;</p>
<p>import javax.imageio.*;<br />
import javax.imageio.event.*;<br />
import javax.imageio.stream.*;</p>
<p>public class TestClass implements IIOReadProgressListener, IIOReadUpdateListener, IIOReadWarningListener<br />
{<br />
	public TestClass() throws IOException<br />
	{<br />
		ImageInputStream iis = ImageIO.createImageInputStream(new File("/home/kading/Development/diatheek/photos/152/Inv.1474.tif"));<br />
		if (iis == null)<br />
			return;<br />
		Iterator readers = ImageIO.getImageReaders(iis);<br />
		if(readers.hasNext())<br />
		{<br />
			ImageReader reader = (ImageReader) readers.next();<br />
			reader.addIIOReadProgressListener(this);<br />
			reader.addIIOReadUpdateListener(this);<br />
			reader.addIIOReadWarningListener(this);<br />
			reader.setInput(iis, true);<br />
			BufferedImage originalImage = reader.read(0);<br />
		}<br />
	}</p>
<p>	public static void main(String[] args) throws Exception<br />
	{<br />
		new TestClass();<br />
	}</p>
<p>	public void imageComplete(ImageReader source)<br />
	{<br />
		System.out.println( "image complete" );<br />
	}</p>
<p>	public void imageProgress(ImageReader source, float percentageDone)<br />
	{<br />
		System.out.println( "image progress: " + percentageDone );<br />
	}</p>
<p>	public void imageStarted(ImageReader source, int imageIndex)<br />
	{<br />
		System.out.println( "image started" );<br />
	}</p>
<p>	public void readAborted(ImageReader source)<br />
	{<br />
		System.out.println( "read aborted" );<br />
	}</p>
<p>	public void sequenceComplete(ImageReader source)<br />
	{<br />
		System.out.println( "sequence complete" );<br />
	}</p>
<p>	public void sequenceStarted(ImageReader source, int minIndex)<br />
	{<br />
		System.out.println( "sequence started" );<br />
	}</p>
<p>	public void thumbnailComplete(ImageReader source)<br />
	{<br />
		System.out.println( "thumb complete" );<br />
	}</p>
<p>	public void thumbnailProgress(ImageReader source, float percentageDone)<br />
	{<br />
		System.out.println( "thumb progress" );<br />
	}</p>
<p>	public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex)<br />
	{<br />
		System.out.println( "thumb start" );<br />
	}</p>
<p>	public void imageUpdate(ImageReader source, BufferedImage theImage, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands)<br />
	{<br />
		System.out.println( "image update" );<br />
	}</p>
<p>	public void passComplete(ImageReader source, BufferedImage theImage)<br />
	{<br />
		System.out.println( "pass complete" );<br />
	}</p>
<p>	public void passStarted(ImageReader source, BufferedImage theImage, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands)<br />
	{<br />
		System.out.println( "pass started" );<br />
	}</p>
<p>	public void thumbnailPassComplete(ImageReader source, BufferedImage theThumbnail)<br />
	{<br />
		System.out.println( "Thumb pass complete" );<br />
	}</p>
<p>	public void thumbnailPassStarted(ImageReader source, BufferedImage theThumbnail, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands)<br />
	{<br />
		System.out.println( "Thumb pass start" );<br />
	}</p>
<p>	public void thumbnailUpdate(ImageReader source, BufferedImage theThumbnail, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands)<br />
	{<br />
		System.out.println( "Thumb update" );<br />
	}</p>
<p>	public void warningOccurred(ImageReader source, String warning)<br />
	{<br />
		System.out.println( "Warning: " + warning );<br />
	}<br />
}<br />

Message was edited by: kading

Message was edited by: kading

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kading
Offline
Joined: 2003-11-24
Points: 0

Thanks for the tips. I did some more test, using pyramid tiled TIFF as well as normal TIFFs. However, the tiling was not the issue. Apparently uncompressed TIFF files did not have a proper progress update. The same images (tiled or non-tiled) with LWZ compression did update frequently.

Brian Burkhalter

On Wed, 6 Jun 2007, jai-imageio@javadesktop.org wrote:

> Thanks for the tips. I did some more test, using pyramid tiled TIFF as well as normal TIFFs. However, the tiling was not the issue. Apparently uncompressed TIFF files did not have a proper progress update. The same images (tiled or non-tiled) with LWZ compression did update frequently.

If you found that to be the case you must be using a different version from
what I have. Could you provide a test case to prove it?

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

bpb
Offline
Joined: 2004-06-23
Points: 0

Indeed for your use case this behavior is unacceptable. What is the nature of the large images, e.g., "Inv.1474.tif"? Are they RGB? Tiled or untiled?

> Hello everyone. Do the TIFF reader in Java image I/O
> not update the IIOReadProgressListeners? The method
> 'imageProgress' only gets called twice, at 0% and at
> 100% done. My application is intented to load large
> TIFF images (40-200MB) over a fairly slow local area
> network. It is important that users get a progress
> indicator.
>
> Anyone know what is going on and even more
> importantly how to get it to work? Thanks in advance
> for any help! :)
>
> Florian Kading
>
> A test application showing the problem:
> [code]
> import java.awt.image.*;
> import java.io.*;
> import java.util.*;
>
> import javax.imageio.*;
> import javax.imageio.event.*;
> import javax.imageio.stream.*;
>
> public class TestClass implements
> IIOReadProgressListener, IIOReadUpdateListener,
> IIOReadWarningListener
> {
> public TestClass() throws IOException
> {
> ImageInputStream iis =
> = ImageIO.createImageInputStream(new
> File("/home/kading/Development/diatheek/photos/152/Inv
> .1474.tif"));
> if (iis == null)
> return;
> Iterator readers = ImageIO.getImageReaders(iis);
> if(readers.hasNext())
> {
> ImageReader reader = (ImageReader)
> er) readers.next();
> reader.addIIOReadProgressListener(this);
> reader.addIIOReadUpdateListener(this);
> reader.addIIOReadWarningListener(this);
> reader.setInput(iis, true);
> BufferedImage originalImage = reader.read(0);
> }
> }
>
> public static void main(String[] args) throws
> s Exception
> {
> new TestClass();
> }
>
> public void imageComplete(ImageReader source)
> {
> System.out.println( "image complete" );
> }
>
> public void imageProgress(ImageReader source, float
> t percentageDone)
> {
> System.out.println( "image progress: " +
> + percentageDone );
> }
>
> public void imageStarted(ImageReader source, int
> t imageIndex)
> {
> System.out.println( "image started" );
> }
>
> public void readAborted(ImageReader source)
> {
> System.out.println( "read aborted" );
> }
>
> public void sequenceComplete(ImageReader source)
> {
> System.out.println( "sequence complete" );
> }
>
> public void sequenceStarted(ImageReader source, int
> t minIndex)
> {
> System.out.println( "sequence started" );
> }
>
> public void thumbnailComplete(ImageReader source)
> {
> System.out.println( "thumb complete" );
> }
>
> public void thumbnailProgress(ImageReader source,
> , float percentageDone)
> {
> System.out.println( "thumb progress" );
> }
>
> public void thumbnailStarted(ImageReader source, int
> t imageIndex, int thumbnailIndex)
> {
> System.out.println( "thumb start" );
> }
>
> public void imageUpdate(ImageReader source,
> , BufferedImage theImage, int minX, int minY, int
> width, int height, int periodX, int periodY, int[]
> bands)
> {
> System.out.println( "image update" );
> }
>
> public void passComplete(ImageReader source,
> , BufferedImage theImage)
> {
> System.out.println( "pass complete" );
> }
>
> public void passStarted(ImageReader source,
> , BufferedImage theImage, int pass, int minPass, int
> maxPass, int minX, int minY, int periodX, int
> periodY, int[] bands)
> {
> System.out.println( "pass started" );
> }
>
> public void thumbnailPassComplete(ImageReader
> r source, BufferedImage theThumbnail)
> {
> System.out.println( "Thumb pass complete" );
> }
>
> public void thumbnailPassStarted(ImageReader source,
> , BufferedImage theThumbnail, int pass, int minPass,
> int maxPass, int minX, int minY, int periodX, int
> periodY, int[] bands)
> {
> System.out.println( "Thumb pass start" );
> }
>
> public void thumbnailUpdate(ImageReader source,
> , BufferedImage theThumbnail, int minX, int minY, int
> width, int height, int periodX, int periodY, int[]
> bands)
> {
> System.out.println( "Thumb update" );
> }
>
> public void warningOccurred(ImageReader source,
> , String warning)
> {
> System.out.println( "Warning: " + warning );
> }
> }
> [/code]
>
> Message was edited by: kading
>
> Message was edited by: kading

bpb
Offline
Joined: 2004-06-23
Points: 0

Actually I think I know the answer. It looks as if the TIFF reader only updates the progress listener after each tile. Therefore if the image is untiled you only get one update. Unfortunately the actual decoding of each tile is handled by a TIFFDecompressor which currently has no concept of a progress listener. Some work would be require to fix this.

Would you mind filing this as an ENHANCEMENT request in the jai-imageio-core project Issue Tracker? Issues filed by users get higher priority than those filed by us.

> Indeed for your use case this behavior is
> unacceptable. What is the nature of the large images,
> e.g., "Inv.1474.tif"? Are they RGB? Tiled or
> untiled?
>
> > Hello everyone. Do the TIFF reader in Java image
> I/O
> > not update the IIOReadProgressListeners? The
> method
> > 'imageProgress' only gets called twice, at 0% and
> at
> > 100% done. My application is intented to load
> large
> > TIFF images (40-200MB) over a fairly slow local
> area
> > network. It is important that users get a progress
> > indicator.
> >
> > Anyone know what is going on and even more
> > importantly how to get it to work? Thanks in
> advance
> > for any help! :)
> >
> > Florian Kading
> >
> > A test application showing the problem:
> > [code]
> > import java.awt.image.*;
> > import java.io.*;
> > import java.util.*;
> >
> > import javax.imageio.*;
> > import javax.imageio.event.*;
> > import javax.imageio.stream.*;
> >
> > public class TestClass implements
> > IIOReadProgressListener, IIOReadUpdateListener,
> > IIOReadWarningListener
> > {
> > public TestClass() throws IOException
> > {
> > ImageInputStream iis =
> > = ImageIO.createImageInputStream(new
> >
> File("/home/kading/Development/diatheek/photos/152/Inv
>
> > .1474.tif"));
> > if (iis == null)
> > return;
> > Iterator readers = ImageIO.getImageReaders(iis);
> > if(readers.hasNext())
> > {
> > ImageReader reader = (ImageReader)
> > er) readers.next();
> > reader.addIIOReadProgressListener(this);
> > reader.addIIOReadUpdateListener(this);
> > reader.addIIOReadWarningListener(this);
> > reader.setInput(iis, true);
> > BufferedImage originalImage = reader.read(0);
> > }
> > }
> >
> > public static void main(String[] args) throws
> > s Exception
> > {
> > new TestClass();
> > }
> >
> > public void imageComplete(ImageReader source)
> > {
> > System.out.println( "image complete" );
> > }
> >
> > public void imageProgress(ImageReader source,
> float
> > t percentageDone)
> > {
> > System.out.println( "image progress: " +
> > + percentageDone );
> > }
> >
> > public void imageStarted(ImageReader source, int
> > t imageIndex)
> > {
> > System.out.println( "image started" );
> > }
> >
> > public void readAborted(ImageReader source)
> > {
> > System.out.println( "read aborted" );
> > }
> >
> > public void sequenceComplete(ImageReader source)
> > {
> > System.out.println( "sequence complete" );
> > }
> >
> > public void sequenceStarted(ImageReader source,
> int
> > t minIndex)
> > {
> > System.out.println( "sequence started" );
> > }
> >
> > public void thumbnailComplete(ImageReader source)
> > {
> > System.out.println( "thumb complete" );
> > }
> >
> > public void thumbnailProgress(ImageReader source,
> > , float percentageDone)
> > {
> > System.out.println( "thumb progress" );
> > }
> >
> > public void thumbnailStarted(ImageReader source,
> int
> > t imageIndex, int thumbnailIndex)
> > {
> > System.out.println( "thumb start" );
> > }
> >
> > public void imageUpdate(ImageReader source,
> > , BufferedImage theImage, int minX, int minY, int
> > width, int height, int periodX, int periodY, int[]
> > bands)
> > {
> > System.out.println( "image update" );
> > }
> >
> > public void passComplete(ImageReader source,
> > , BufferedImage theImage)
> > {
> > System.out.println( "pass complete" );
> > }
> >
> > public void passStarted(ImageReader source,
> > , BufferedImage theImage, int pass, int minPass,
> int
> > maxPass, int minX, int minY, int periodX, int
> > periodY, int[] bands)
> > {
> > System.out.println( "pass started" );
> > }
> >
> > public void thumbnailPassComplete(ImageReader
> > r source, BufferedImage theThumbnail)
> > {
> > System.out.println( "Thumb pass complete" );
> > }
> >
> > public void thumbnailPassStarted(ImageReader
> source,
> > , BufferedImage theThumbnail, int pass, int
> minPass,
> > int maxPass, int minX, int minY, int periodX, int
> > periodY, int[] bands)
> > {
> > System.out.println( "Thumb pass start" );
> > }
> >
> > public void thumbnailUpdate(ImageReader source,
> > , BufferedImage theThumbnail, int minX, int minY,
> int
> > width, int height, int periodX, int periodY, int[]
> > bands)
> > {
> > System.out.println( "Thumb update" );
> > }
> >
> > public void warningOccurred(ImageReader source,
> > , String warning)
> > {
> > System.out.println( "Warning: " + warning );
> > }
> > }
> > [/code]
> >
> > Message was edited by: kading
> >
> > Message was edited by: kading