By slicing a very large image of a jpg map, 49000 * 34300 pixels

I want to write mapviewer, I have to work with small tiles of a large image file with a map, and there is a need for tiles of a large image, now the problem is to split the large image into small tiles (250 * 250 pixels or whatever the size is) and so Further, I used ImageMagic for this, but was there a problem now is there any other software method or application that does tiling? can i do this with jai in java? as?

+4
source share
6 answers

Have you tried to do this in java yourself? I tried this with (WARNING, a large image may crash your browser, use "save as ...") this image . You need to work with additional memory ( -Xmx400M ).

 public class ImageTile { public static void main(String[] args) throws IOException { Dimension tileDim = new Dimension(250, 250); BufferedImage image = ImageIO.read(new File(args[0])); Dimension imageDim = new Dimension(image.getWidth(), image.getHeight()); for(int y = 0; y < imageDim.height; y += tileDim.height) { for(int x = 0; x < imageDim.width; x += tileDim.width) { int w = Math.min(x + tileDim.width, imageDim.width) - x; int h = Math.min(y + tileDim.height, imageDim.height) - y; BufferedImage tile = image.getSubimage(x, y, w, h); ImageIO.write(tile, "JPG", new File("tile-"+x+"-"+y+".jpg")); } } } } 
+5
source

For large image sizes, just like yours, you will be best off working with lossless JPEG editing. This is not only faster because the image does not need to be rendered, but it also retains quality because the image is not compressed.

Lossless processing works on blocks, usually 16 pixels square. Although this is a limitation for some applications, this seems like a good help for matching. You can implement tiles with different zoom levels, first cropping the image to size without loss. (This is quickly effective because the image is not displayed.) It gives you fragments for full-scale scaling. To create a lower zoom level, combine 2x2 tiles and scale them to the size of 1 tile. The next level uses 4x4 tiles and 8x8, etc., each time reducing to one tile. At some point, when the number of tiles is too large, you can use scaled tiles as a base resource. For example, when scaling 8, which requires 256x256 tiles. This may be too much to process, so you can use 16x16 tiles from level 4.

Wikipedia is more about lossless editing and links to some executing libraries.

+3
source

imagemagick does tiling using - tile . It is rather a repetition of an image, but may be especially useful. since you are already using it. However, if you mean the generated seamless tile, I'm not sure if imagemagick can do this or not.

0
source

GDAL comes with a script called gdal2tiles.py that does exactly what you want, including formatting tiles for use with Google Maps, OpenLayers, etc.

There seems to be a newer version of GDAL2Tiles .

0
source

What about megatexture with r-tree for efficient access? Apparently, it can use images of 128000x128000 pixels.

0
source

JAI is platform dependent and today seems like a dead project.

I recommend using the open source imagemagick program . Although platform dependent, it is available for the same platforms as JAI, but with full community support.

The focus on large images about imagemagick uses its stream "command instead of convert . Stream only reads the corresponding part of the image and saves the extracted part as raw data. Then you need to" convert "to save small raw data as jpeg.

An example of saving a tile from large.jpeg of size 800x600 from position 0x0 to tile.jpeg:

  stream -extract 800x600+0+0 large.jpeg tile.rgb convert -depth 8 -size 800x600 rgb:tile.rgb tile.jpeg 

(When working on Windows, be sure to use ImageMagick convert.exe, as there is a windows command called "convert".)

When working only with TIFF images, apache Sanselan might be the right choice - this is a pure-java image library. Additionally, the JAI seems to contain a platform-independent codec for TIFF.

0
source

Source: https://habr.com/ru/post/1307083/


All Articles