Guest User

Untitled

a guest
Jul 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public void getImageDimensions(String loc) {
  2. File fil = new File(loc);
  3. if (!fil.exists() || !fil.isDirectory())
  4. return;
  5. for (File f : fil.listFiles()) {
  6. if (isImage(f)) {
  7. try {
  8. BufferedImage img = ImageIO.read(f);
  9. System.out.println(f.getName() + ": " + img.getWidth()
  10. + "," + img.getHeight());
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }
  15. }
  16. }
  17.  
  18. private boolean isImage(File f) {
  19. String name = f.getName().toLowerCase();
  20. return name.endsWith(".gif") || name.endsWith(".jpg")
  21. || name.endsWith(".png");
  22. }
Add Comment
Please, Sign In to add comment