-4

i had been working on my project which encompasses the technique for comparing images. I want to compare two images in java in terms of height and width, i can't compare it if any one can help it please do..

Shubham
  • 25
  • 6

1 Answers1

0

Here is a head start. You can use something like this and that should get you going.

Image image;

public static void listFilesForFolder(File folder) {
    for (final File fileEntry : folder.listFiles()) {

        Image image;

        try {


            image = ImageIO.read(new File("C://Users//workspace//ImageProcessing//images//" + fileEntry.getName()));

            BufferedImage buffered = (BufferedImage) image;

            int imageHeight = image.getHeight(null);
            int imageWidth = image.getWidth(null);
            yourImageClass.setHeight(imageHeight);
            yourImageClass.setWidth(imageWidth);
            arrayListOfImageClasses.add(yourImageClass);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println(fileEntry.getName());

    }
}

These are the jars you can use :

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;           

Hope this gets you going.

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108