There's no "easy" way to do what you are proposing.
First there's the question of equality. If you I show you two pictures of the same thing, you will right away say, yes they are the same?
Why, because all of the pixels look the same, right? The problem is that you don't care about minor details that may be different, but the computer DOES.
Naively:
You could just do a pixel-by-pixel comparison, which is what I suspect you want to do.
public static boolean comparePics(BufferedImage img1, BufferedImage img2){
int w = img1.getWidth();
int h = img1.getHeight();
if(w == img2.getWidth() && h == img2.getHeight()){
for(int i = 0; i < w; ++i){
for(int j = 0; j < h; ++j){
int c1 = img1.getRGB(i, j);
int c2 = img2.getRGB(i, j);
if(c1 != c2){
return false;
}
}
}
}else{
return false;
}
return true
}
That may not be completely syntactically correct, but you should be just missing a parenthesis or something.
WARNING:
If you have two pictures that are not the same size, then don't think that you can just scale them and then this will work, because it won't. This algorithm is VERY VERY picky. The likelihood of taking two identical pictures, scaling them to different sizes, then scaling them back and then that giving you back the EXACT same two pictures (pixel-by-pixel) is unlikely.
For instance when you scale a picture down, pixels have to be removed, so you are removing information, that information is no longer accessible from your scaled picture. Also if you scale images to be bigger, then pixels must be added, now you've added "bad" information to your picture.
Seriously, try this, take a picture. Now scale it down to a smaller size, now save as a new picture. Now take the new picture that you just scaled and blow it back up to the size of the original picture, do they look the same? I doubt it.