Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void getImageDimensions(String loc) {
- File fil = new File(loc);
- if (!fil.exists() || !fil.isDirectory())
- return;
- for (File f : fil.listFiles()) {
- if (isImage(f)) {
- try {
- BufferedImage img = ImageIO.read(f);
- System.out.println(f.getName() + ": " + img.getWidth()
- + "," + img.getHeight());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- private boolean isImage(File f) {
- String name = f.getName().toLowerCase();
- return name.endsWith(".gif") || name.endsWith(".jpg")
- || name.endsWith(".png");
- }
Add Comment
Please, Sign In to add comment