Say I have 2 TIF
images and I read one of them into a BufferedImage
instance:
ImageReader reader = ImageIO.getImageReadersByFormatName("tif").next();
reader.setInput(inputStream, false); // inputStream is the first image.
BufferedImage bufferedImage = reader.read(0);
Now I want to create a new BufferedImage
without reading the other image. It should be the same as the previous one, but only different in size. imageType
seems to be 0 for TIF
images, but the following doesn't work.
BufferedImage largeBufferedImage = new BufferedImage(newWidth, newHeight, 0);
Is there any way to clone the existing BufferedImage
and only change its size?
BTW I want to be able to do it for any image format. I don't want to deal with details like imageType
if possible.