-
Frederic Marion-Poll August 3, 2019 at 12:41 am
Hi,
I would like to aggregate images of different sizes into a sequence (typically 20 images). To do so, I would like to find the image with the largest width and height, and then, adjust the size of all the other images, using an algorithm like this: (here, to adjust them to the size of a rectangle called “rectRef”):
IcyBufferedImage ibufImage = null;
try {
ibufImage = Loader.loadImage(filename); // load image in memory
} catch (UnsupportedFormatException | IOException e) {
e.printStackTrace();
}
ibufImage = IcyBufferedImageUtil.getSubImage(ibufImage, rectRef ); // change size of the image
try {
Saver.saveImage(ibufImage, files.get(i), true); // save the file again on the disk
} catch (FormatException | IOException e) {
e.printStackTrace();
}However, this is quite lengthy, especially if the images are TIFF and large, because all files need to be loaded in memory at least once.
Is it possible to read only the header of TIFF files and extract the height and width?
Thank you in advance for any help/suggestion,
Fred
Frederic Marion-Poll August 3, 2019 at 8:52 amIs this a solution?
OMEXMLMetadata metaData = null;
try {
metaData = Loader.getOMEXMLMetaData(path);
} catch (UnsupportedFormatException | IOException e) {
e.printStackTrace();
}
int imageWidth = MetaDataUtil.getSizeX(metaData, 0);
int imageHeight= MetaDataUtil.getSizeY(metaData, 0);Stephane Dallongeville August 5, 2019 at 9:52 amHi Frederic,
Yeah, that is the method to use: load metadata and read it. Depending image file format even metadata can take a bit of time to read but it will be much faster than loading all image data itself.
Best,
– Stephane
The forum ‘Development’ is closed to new topics and replies.