0

I have a big geotiff files that I try to split into small png images, using Java language, I cannot read all the picture into a BuffredImage, so I just want to read it and save it as 2 png pictures.

My question is How to split this big geotiff to 2 png or jpeg images and save theme on disk?

Javaist
  • 139
  • 6
  • What is the question here? – Søren Boisen Jun 01 '15 at 18:15
  • Sorry, I just edited it – Javaist Jun 01 '15 at 18:18
  • There's probably no pure-Java solution for this, but you could use an utility like `tiffmakemosaic` from [LargeTIFFTools](http://www.imnc.in2p3.fr/pagesperso/deroulers/software/largetifftools/) for splitting the images. – Mick Mnemonic Jun 01 '15 at 18:20
  • @MickMnemonic thank you very much, can you just write your comment as answer in order to close this question – Javaist Jun 01 '15 at 18:46
  • No problem, I'll add an answer later. I hope LargeTIFFTools works for you. I haven't yet tried it myself, but I soon intend to as I need such a tool for splitting multi-GB tiffs myself. – Mick Mnemonic Jun 01 '15 at 18:52

2 Answers2

1

Using Java ImageIO you should be able to read only parts of the file into memory. If the TIFF file is tiled you can read individual tiles using ImageReader.readTile(int, int, int). Otherwise you can use ImageReader.read(int, ImageReadParam) with an ImageReadParam that you have called setSourceRegion on.

However

Support for these features depends on the actual ImageReader implementation. In this case, no ImageReader for geotiff files is supplied with Java ImageIO, so you will need to get it elsewhere. Since geotiff is fully compliant with TIFF 6.0, you can use an ordinary TIFF reader, if you don't need the additional geo data. There is one included in JAI. I also found a full geotiff reader here: GeoTools. I do not know if either of these ImageReaders support reading partial images though.

Community
  • 1
  • 1
Søren Boisen
  • 1,669
  • 22
  • 41
1

There's probably no pure-Java solution for splitting very large TIFF files into smaller ones. However, you could use an utility like tiffmakemosaic from LargeTIFFTools for splitting the images. The utility comes with built-in functionality for converting the split images into JPEG format.

If you need your images as PNGs, you can use e.g. the ImageIO library as suggested in this thread.

Community
  • 1
  • 1
Mick Mnemonic
  • 7,808
  • 2
  • 26
  • 30