Skip to main content

JAI encode is taking time

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
tabs
Offline
Joined: 2011-07-04
Points: 0

Hi,

I'm using JAI to split tiff images into pages. For splitting, we are using ImageDecoder & ImageEncoder. And while ecoding image its taking almost 40 seconds. Is there any other way to encode image.

Here is the sample encoding code :

//we are splitting the image into pages and storing it in the list

image = decoder.decodeAsRenderedImage((pageIndex));
System.out.println(image);
pagesLst.add(image);

getPageBytes(pagesLst);

//Method to get page into bytes array

private static byte[] getPageBytes(List pagesLst){

//getting first rendered page

RenderedImage firstImage = (RenderedImage) pagesLst.get(0);

TIFFEncodeParam param = new TIFFEncodeParam();
param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out,
param);

// Encode the first image.

encoder.encode(firstImage); // THIS LINE IS TAKING MORE TIME

}

Any help would be appreciate.

Thanks,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jthaddeus
Offline
Joined: 2005-12-15
Points: 0

There's an example here:
http://www.rgagnon.com/javadetails/java-0535.html
but it may be no faster than what you're doing.

While I prefer working in Java, if I were doing this on an industrial scale,
I think I'd use libtiff (http://www.libtiff.org/) to read the image and lots
of memcpy().

On Wed, Jul 27, 2011 at 4:45 AM, wrote:

> Hi,
>
> I'm using JAI to split tiff images into pages. For splitting, we are using
> ImageDecoder & ImageEncoder. And while ecoding image its taking almost 40
> seconds. Is there any other way to encode image.
>
> Here is the sample encoding code :
>
> //we are splitting the image into pages and storing it in the list
>
> image = decoder.decodeAsRenderedImage(**(pageIndex));
> System.out.println(image);
> pagesLst.add(image);
>
> getPageBytes(pagesLst);
>
> //Method to get page into bytes array
>
> private static byte[] getPageBytes(List pagesLst){
>
> //getting first rendered page
>
> RenderedImage firstImage = (RenderedImage) pagesLst.get(0);
>
> TIFFEncodeParam param = new TIFFEncodeParam();
> param.setCompression(**TIFFEncodeParam.COMPRESSION_**GROUP4);
> ImageEncoder encoder = ImageCodec.createImageEncoder(**"TIFF", out,
> param);
>
> // Encode the first image.
>
> encoder.encode(firstImage); // THIS LINE IS TAKING MORE TIME
>
>
>
> }
>
> Any help would be appreciate.
>
> Thanks,
>
>
>