Home arrow static arrow Java Programming [Archive] - TIFFDecodeParam, TIFFEncodeParam
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - TIFFDecodeParam, TIFFEncodeParam
This topic has 3 replies on 1 page.

Registered: 12/27/02
TIFFDecodeParam, TIFFEncodeParam  
Jan 16, 2003 9:34 AM

I have been playing around with TIFFs in a little Java sample I have modified. The original sample read in the first image contained in a TIFF file and displayed it in a ScollingImagePane.

I modified it so that it reads in every image, and saves each as a new TIFF. My test TIFF file contains 2 images, so I end up with 2 new TIFF images. This is my beef:

Height: 11.06" (2168 pixels)
Width: 8.47" (1728 pixels)
Resolution: 204 x 196 dpi
Colors: Black & White
Compression: CCITT Group3 (1d) fax

Height: 22.68" (2168 pixels)
Width: 17.28" (1728 pixels)
Resolution: 100 x 100 dpi
Colors: Black & White
Compression: CCITT Group3 (1d) fax

No information is lost, however, the resulting images are blown up 2x!
Does anyone know why this is?
If so, is this fixable?
I have looked through all the documentation on this that I could find, but could not find anything which can change the resolution of the resulting TIFF files.

Registered: 11/5/02
Re: TIFFDecodeParam, TIFFEncodeParam  
Jan 14, 2004 2:06 AM (reply 1 of 3)

i have a similar problem with JAI
I read a multipage tiff form fax and i split in several single page.
I some files the size and orientation of image, that i see in windows utility normally,is changed.
For example a vertical orietation go horizontal ....abd the size is bigger

Registered: 8/4/03
Re: TIFFDecodeParam, TIFFEncodeParam  
Jun 18, 2004 10:16 AM (reply 2 of 3)

did you get any resolution to this problem? i am having the exact same issue. my images are coming out as landscape when they should be portrait.

here is my code:

 public ArrayList processImage(byte[] data)   {      byte[] compressedData = null;      ArrayList blobDataList = new ArrayList();       try      {         SeekableStream s = new ByteArraySeekableStream(data);         ImageDecoder dec = ImageCodec.createImageDecoder("TIFF", s, null);          int numPages = dec.getNumPages();         Trace.debug("tiff image has " + numPages + " pages.");          for (int i = 0; i < numPages; i++)         {            // Which of the multiple images in the TIFF file do we want to load            // 0 refers to the first, 1 to the second and so on.            RenderedImage op = new NullOpImage(dec.decodeAsRenderedImage(i), null,                                               null, OpImage.OP_COMPUTE_BOUND);             ByteArrayOutputStream output = new ByteArrayOutputStream();             ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", output, null);            encoder.encode(op);             // new byte[] with new tiff image data            compressedData = output.toByteArray();             output.close();           // some stuff .......             blobDataList.add(xxxxxxx);          }       }      catch (IOException fio)      {         Trace.error("io exception:", fio);         return null;      }       return blobDataList;   } 

thanks for any info.


Registered: 10/2/02
Re: TIFFDecodeParam, TIFFEncodeParam  
Jul 2, 2004 2:07 PM (reply 3 of 3)

The reason why your image is twice as large is you have cut the dpi in half but the pixel number is the same. You have to reduce your pixels, not the dpi
This topic has 3 replies on 1 page.