title: How to resize tiff image in java?
body: <p>I want to resize a .tiff file. I have used JAI toolkit to resize different types of images. Here is what I have tried to implement:</p>
  
  <pre><code>int imageWidth = 330;
          int imageHeight = 490;
  
          BufferedImage tempImage = new BufferedImage(imageWidth, imageHeight,BufferedImage.TYPE_INT_RGB);
          Graphics2D graphics2D = tempImage.createGraphics();
          graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
          graphics2D.drawImage(tempImage, 0, 0, imageWidth, imageHeight, null);
          graphics2D.dispose();           
  
          File outfile = new File("D:/Work/YoursGallery/output.tif");
  
          BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outfile));
  
          FileSeekableStream ss = new FileSeekableStream("D:/Work/YoursGallery/sample1.tif");
  
          ImageDecoder dec = ImageCodec.createImageDecoder("tiff", ss, null);  
          TIFFEncodeParam param = new TIFFEncodeParam();
          param.setTileSize(tempImage.getWidth(), tempImage.getHeight());
  
  
          TIFFImageEncoder encoder = (TIFFImageEncoder) TIFFCodec.createImageEncoder("tiff", out, param);         
          encoder.encode(dec.decodeAsRenderedImage());
  
          out.close();
  </code></pre>
  
  <p>The image created is having same size as original image has. Can anyone please tell what  is the issue?</p>
  
  <p>Here is the sample tiff image which I am using to test it.</p>
  
  <p><a href="http://docs.google.com/fileview?id=0BxCDhEXNFvbeMTYyMGZmNDYtODhhNy00YWI3LTkxNDgtZTNhM2FhMjg5Y2Q3&amp;hl=en&amp;authkey=CPCEypgM" rel="nofollow noreferrer">http://docs.google.com/fileview?id=0BxCDhEXNFvbeMTYyMGZmNDYtODhhNy00YWI3LTkxNDgtZTNhM2FhMjg5Y2Q3&amp;hl=en&amp;authkey=CPCEypgM</a></p>
  
  <p>Thanks in advance.</p>