title: Creating Thumbnail for TIFF image in JAVA
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1954685/cant-read-and-write-a-tiff-image-file-using-java-imageio-standard-library">Can&#39;t read and write a TIFF image file using Java ImageIO standard library</a>  </p>
  </blockquote>
  
  
  
  <p>Can someone please help with some code for creating a thumbnail for a TIFF in Java.
  Using this <a href="https://stackoverflow.com/questions/1069095/how-do-you-create-a-thumbnail-image-out-of-a-jpeg-in-java">Post</a> have created thumbnail for JPEG and PNG. I have used the below code to create thumbanail for PNG and JPEG</p>
  
  <pre><code>BufferedImage image = ImageIO.read(aFile);
      BufferedImage thumbnNailImage = new BufferedImage(width, height,
              BufferedImage.TYPE_INT_RGB);
  
      Graphics2D g2 = thumbnNailImage.createGraphics();
      g2.fillRect(0, 0, width, height);
  
      double xScale = (double) width / image.getWidth();
      double yScale = (double) height / image.getHeight();
      double scale = Math.min(xScale, yScale);
  
      double x = (width - image.getWidth() * scale) / 2;
      double y = (height - image.getHeight() * scale) / 2;
      AffineTransform at = AffineTransform.getScaleInstance(x, y);
      at.scale(scale, scale);
      g2.drawRenderedImage(image, at);
      g2.dispose();
      return thumbnNailImage;  
  </code></pre>