Hi,
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:
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();
The image created is having same size as original image has. Can anyone please tell what is the issue?
Here is the sample tiff image which I am using to test it.
Thanks in advance.