Pixel-by-pixel is easy, you just hash the image and store the has, then hash the new image and compare the hashes. But that is going to fail if images are scaled, or in case of lossy compressions, re-saved.
That's going to essentially match if somebody uploads the same file twice. This may or may not be what you are after.
If not, you need some sort of image similarity algorithm. There is a question about that already, here. Image comparison - fast algorithm