Hi there,
I'm trying to build an application that encodes and resize images off any type of image and store it as a JPEG.
The current url -> http://gn.vinea.es/inmo.nsf/vwimagen/2031225200800143/$File/f225200800143.JPG is a kind of weird jpeg and use for testing.
For some reason JAI cannot render this image as a JPEG. I use the following code: ... private SeekableStream seekableStream; ... public RenderedOp builRenderedOp(byte[] bytes) { seekableStream = SeekableStream.wrapInputStream(new ByteArrayInputStream(bytes),true); RenderedOp img = JAI.create("stream", seekableStream); return img ; } ... public void writeImageToJPEG(OutputStream out,RenderedOp image,float quality) throws IOException { JPEGEncodeParam encodeParam = new JPEGEncodeParam(); encodeParam.setQuality(quality);
ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", out, encodeParam);
encoder.encode(image);
}
on encoder.encode(image) a RuntimeException is thrown. java.lang.RuntimeException: - Unable to render RenderedOp for this operation. at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:838) at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878) at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2190) ....
Any suggestions