Created
May 2, 2014 09:37
-
-
Save dedunumax/50ae2cf488f55d05e945 to your computer and use it in GitHub Desktop.
This program will cut a single image into several image files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dedunumax.imagecutter; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
public class ImageCutter { | |
public static void main(String[] args) throws IOException { | |
File path = new File("/home/images/"); | |
int margin = 38, padding = 18, dimension = 640, numberOfImages = 23; | |
BufferedImage image = ImageIO.read(new File(path, "full.png")); | |
for (int i = 0; i < numberOfImages; i++) { | |
System.out.println("Index : " + i + " Y: " | |
+ ((dimension + padding) * i) + margin); | |
BufferedImage temp = image.getSubimage(0, | |
((dimension + padding) * i) + margin, dimension, dimension); | |
ImageIO.write(temp, "PNG", new File(path, "Figure_" + (i + 1) | |
+ ".png")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment