Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split an image into parts [closed]

I know that there are a lot of topics about this, but none really fits into my problem. I need the attached image (link) divided into multiple sub-images and I search for the easiest way to do this.

The image should be saveable. I tried BufferedImage, which lacks a useful constructor for this.

It doesn't have to be java. A simple tool who can do this would also do the job. Note: I have to get ~567 images out of one. I found "online image-splitters", but none was able to split the image into more than 32 parts.

like image 912
codepleb Avatar asked Aug 07 '14 23:08

codepleb


Video Answer


1 Answers

final BufferedImage source = ImageIO.read(new File("<sourceDir>/1fby-6t-555d.png"));
int idx = 0;
for (int y = 0; y < source.getHeight(); y += 32) {
    ImageIO.write(source.getSubimage(0, y, 32, 32), "png", new File("<sourceDir>/1fby-6t-555d_" + idx++ + ".png"));
}

:)


Output:

enter image description here

like image 168
ccjmne Avatar answered Sep 18 '22 01:09

ccjmne