Skip to main content

[JAVA2D] Unable to convert 32bpp TIFFs to PNG.

4 replies [Last post]
Anonymous

Hi,

I have a small image processing servlet, that does;

m_Format = "png" in this case.

private void write( BufferedImage image )
throws ProcessingException, IOException
{
ImageTypeSpecifier its = ImageTypeSpecifier.createFromRenderedImage(
image );
Iterator writers = ImageIO.getImageWriters( its, m_Format );
ImageWriter writer = null;
if( writers.hasNext() )
{
writer = (ImageWriter) writers.next();
}
if( writer == null )
throw new ProcessingException( "Unable to find a ImageWriter: " +
m_Format );

/// And so on....
}
The effectsStack is basically a set of ImageOp's, mostly used is the Scale.

Now, if I take a 32bpp TIFF and feed it to the routine above, Image I/O won't
find a writer for it, but a 24bpp TIFF is no problem.
(I don't think it matters; prior to the write operation, the TIFF has been
rescaled using java.awt.image raster operations, but the ColorModel from the
incoming BufferedImage is used for the new rescaled image.)

Anyone have a clue why this seems to be the case?

Cheers
Niclas
--
+------//-------------------+
/ http://www.dpml.net /
/ http://niclas.hedhman.org /
+------//-------------------+

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

Niclas,

That should work. Could you give some more detail about the details of the
SampleModel and ColorModel in the ImageTypeSpecifier, e.g., number of bands,
bits per sample, alpha presence, alpha type.

Brian

On Tue, 7 Dec 2004, Niclas Hedhman wrote:

> Hi,
>
> I have a small image processing servlet, that does;
>
> m_Format = "png" in this case.
>
> private void write( BufferedImage image )
> throws ProcessingException, IOException
> {
> ImageTypeSpecifier its = ImageTypeSpecifier.createFromRenderedImage(
> image );
> Iterator writers = ImageIO.getImageWriters( its, m_Format );
> ImageWriter writer = null;
> if( writers.hasNext() )
> {
> writer = (ImageWriter) writers.next();
> }
> if( writer == null )
> throw new ProcessingException( "Unable to find a ImageWriter: " +
> m_Format );
>
> /// And so on....
> }
> The effectsStack is basically a set of ImageOp's, mostly used is the Scale.
>
> Now, if I take a 32bpp TIFF and feed it to the routine above, Image I/O won't
> find a writer for it, but a 24bpp TIFF is no problem.
> (I don't think it matters; prior to the write operation, the TIFF has been
> rescaled using java.awt.image raster operations, but the ColorModel from the
> incoming BufferedImage is used for the new rescaled image.)
>
>
> Anyone have a clue why this seems to be the case?
>
>
> Cheers
> Niclas
> --
> +------//-------------------+
> / http://www.dpml.net /
> / http://niclas.hedhman.org /
> +------//-------------------+
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
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, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Niclas Hedhman

On Wednesday 08 December 2004 02:34, Brian Burkhalter wrote:

> That should work. Could you give some more detail about the details of the
> SampleModel and ColorModel in the ImageTypeSpecifier, e.g., number of
> bands, bits per sample, alpha presence, alpha type.

Not *that* easily. It has been reported to me by a customer, and the images
are a bit large (~10MB each), so I haven't downloaded any of them into my
environment. I will do so, since you request it :o) I'll look into it
tomorrow.

Another update just came in; If changing to a "jpeg" type, it works, but not
"jpg"... so the urgency drop by a magnitude.

Cheers
Niclas
--
+------//-------------------+
/ http://www.dpml.net /
/ http://niclas.hedhman.org /
+------//-------------------+

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Brian Burkhalter

On Wed, 8 Dec 2004, Niclas Hedhman wrote:

> On Wednesday 08 December 2004 02:34, Brian Burkhalter wrote:
>
> > That should work. Could you give some more detail about the details of the
> > SampleModel and ColorModel in the ImageTypeSpecifier, e.g., number of
> > bands, bits per sample, alpha presence, alpha type.
>
> Not *that* easily. It has been reported to me by a customer, and the images
> are a bit large (~10MB each), so I haven't downloaded any of them into my
> environment. I will do so, since you request it :o) I'll look into it
> tomorrow.

I don't think I can give an answer without more information. Perhaps one of
the Java2D guys can.

Since TIFF is being used, I assume, perhaps incorrectly, that JAI-Image I/O is
also being used. Therefore there are two PNG plug-ins at issue: the one in
JAI-Image I/O and the one in J2SE.

> Another update just came in; If changing to a "jpeg" type, it works, but not
> "jpg"... so the urgency drop by a magnitude.

Note that "JPEG"/"jpeg" is the format name but "JPG""jpg" is the file suffix.

Brian

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
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, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Niclas Hedhman

On Tuesday 07 December 2004 19:38, Niclas Hedhman wrote:
> The effectsStack is basically a set of ImageOp's, mostly used is the Scale.

Disregard this sentence, it was part of a much larger code block which
included the entire sequence.

Thanks
Niclas

--
+------//-------------------+
/ http://www.dpml.net /
/ http://niclas.hedhman.org /
+------//-------------------+

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".