Skip to main content

jpg getRendering() throws factory fails exception

3 replies [Last post]
jweinstock
Offline
Joined: 2006-05-05
Points: 0

I have a .jpg image that opens fine in Photoshop but when I attempt to create execute the following line I get the exception below:

RenderedOp objImage = JAI.create("stream", s);
*((OpImage) objImage.getRendering()).setTileCache(null);

For some reason the getRendering() operation yields the following exception. Does anyone know why this mysterious jpg is failing in the getRendering operation and/or what this exception actually means?

Stack trace:
Error: One factory fails for the operation "jpeg"
Occurs in: javax.media.jai.ThreadSafeOperationRegistry
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1682)
at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:110)
at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1682)
at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
at com.rc.fileprocessing.consumers.RCImageConsumer.consumeImage(Unknown Source)
at com.rc.fileprocessing.processors.ImageProcessor.process(Unknown Source)
at com.rc.fileprocessing.processors.ImageProcessor.run(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.rc.model.persistence.proxyhandler.SessionHandler.invoke(Unknown Source)
at $Proxy2.run(Unknown Source)
at com.rc.fileprocessing.utils.threads.ThreadPoolImpl$PoolThread.run(Unknown Source)
Caused by: com.sun.media.jai.codecimpl.util.ImagingException
at com.sun.media.jai.codecimpl.ImagingListenerProxy.errorOccurred(ImagingListenerProxy.java:71)
at com.sun.media.jai.codecimpl.JPEGImage.sendExceptionToListener(JPEGImageDecoder.java:172)
at com.sun.media.jai.codecimpl.JPEGImage.(JPEGImageDecoder.java:117)
at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:53)
at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:96)
at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:52)
... 28 more
Caused by: com.sun.media.jai.codecimpl.util.ImagingException: Unable to process image stream, incorrect format.
... 33 more
Caused by: com.sun.image.codec.jpeg.ImageFormatException: Can't construct a BufferedImage for given COLOR_ID
at sun.awt.image.codec.JPEGImageDecoderImpl.getDecodedColorModel(JPEGImageDecoderImpl.java:312)
at sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
at sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(JPEGImageDecoderImpl.java:210)
at com.sun.media.jai.codecimpl.JPEGImage.(JPEGImageDecoder.java:114)
... 31 more

Reply viewing options

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

It's probably a problem similar to bug

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302282

wherein the underlying bundled JPEG codec wrapped by JAI cannot understand the
image type in question most likely because it is in YCCK, CMYK or some other
non-JFIF color space.

Suggestion: try the J2SE codec Java Image I/O plugin (see javax.imageio.*) or
the JAI-Image I/O Tools JPEG plugin. If neither of these work please let us
know.

You might also see

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4799903

Brian

On Mon, 7 Nov 2005, jai-interest@javadesktop.org wrote:

> I have a .jpg image that opens fine in Photoshop but when I attempt to create execute the following line I get the exception below:
>
> RenderedOp objImage = JAI.create("stream", s);
> *((OpImage) objImage.getRendering()).setTileCache(null);
>
> For some reason the getRendering() operation yields the following exception. Does anyone know why this mysterious jpg is failing in the getRendering operation and/or what this exception actually means?
>
>
> Stack trace:
> Error: One factory fails for the operation "jpeg"
> Occurs in: javax.media.jai.ThreadSafeOperationRegistry
> java.lang.reflect.InvocationTargetException
> at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
> at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1682)
> at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
> at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
> at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:110)
> at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
> at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1682)
> at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
> at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
> at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
> at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
> at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
> at com.rc.fileprocessing.consumers.RCImageConsumer.consumeImage(Unknown Source)
> at com.rc.fileprocessing.processors.ImageProcessor.process(Unknown Source)
> at com.rc.fileprocessing.processors.ImageProcessor.run(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at com.rc.model.persistence.proxyhandler.SessionHandler.invoke(Unknown Source)
> at $Proxy2.run(Unknown Source)
> at com.rc.fileprocessing.utils.threads.ThreadPoolImpl$PoolThread.run(Unknown Source)
> Caused by: com.sun.media.jai.codecimpl.util.ImagingException
> at com.sun.media.jai.codecimpl.ImagingListenerProxy.errorOccurred(ImagingListenerProxy.java:71)
> at com.sun.media.jai.codecimpl.JPEGImage.sendExceptionToListener(JPEGImageDecoder.java:172)
> at com.sun.media.jai.codecimpl.JPEGImage.(JPEGImageDecoder.java:117)
> at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:53)
> at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:96)
> at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:52)
> ... 28 more
> Caused by: com.sun.media.jai.codecimpl.util.ImagingException: Unable to process image stream, incorrect format.
> ... 33 more
> Caused by: com.sun.image.codec.jpeg.ImageFormatException: Can't construct a BufferedImage for given COLOR_ID
> at sun.awt.image.codec.JPEGImageDecoderImpl.getDecodedColorModel(JPEGImageDecoderImpl.java:312)
> at sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
> at sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(JPEGImageDecoderImpl.java:210)
> at com.sun.media.jai.codecimpl.JPEGImage.(JPEGImageDecoder.java:114)
> ... 31 more
> ---
> [Message sent by forum member 'jweinstock' (Jon Weinstock)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=123506&#123506
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Java Multimedia, 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.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

jweinstock
Offline
Joined: 2006-05-05
Points: 0

After some more research I realized that you are correct, the image is a CMYK jpg.

Is there any way to load in the CMYK jpg to convert it to RGB? I tried using the javax.imageio but get an unsupported format error:

BufferedImage bufferedImage=ImageIO.read(originalImageObj);
ParameterBlock block = new ParameterBlock();
block.add(bufferedImage);
RenderedOp objImage = JAI.create("awtImage", block);

Using the JAI create from a SeekableStream yields the familiar factory error.

Whats the best way to read in the CMYK jpg and is there an easy way to convert it to RGB?

Thanks!
Jonathan

Brian Burkhalter

Support for CMYK JPEG reading is uneven at best. We hope to extend the
JAI-Image I/O Tools JPEG reader to better handle these images in the future.

For the time being you might be able to use the core J2SE JPEG reader's
readAsRaster() method to decode the data. You could then copy the data into an
image which had an appropriate CMYK ColorModel attached and then do a color
conversion of that image to RGB. You might need to extract an ICC profile from
the JPGEG image in order to do this.

Brian

On Thu, 5 Jan 2006, jai-interest@javadesktop.org wrote:

> After some more research I realized that you are correct, the image is a CMYK jpg.
>
> Is there any way to load in the CMYK jpg to convert it to RGB? I tried using the javax.imageio but get an unsupported format error:
>
> BufferedImage bufferedImage=ImageIO.read(originalImageObj);
> ParameterBlock block = new ParameterBlock();
> block.add(bufferedImage);
> RenderedOp objImage = JAI.create("awtImage", block);
>
> Using the JAI create from a SeekableStream yields the familiar factory error.
>
> Whats the best way to read in the CMYK jpg and is there an easy way to convert it to RGB?
>
> Thanks!
> Jonathan
> ---
> [Message sent by forum member 'jweinstock' (Jon Weinstock)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=134457&#134457
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
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.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net