What is a good way to check if an image is unique using PHP?

后端 未结 5 1723
失恋的感觉
失恋的感觉 2021-01-20 21:29

What is the best way to check if an image is unique using PHP? Say I have a directory of about 30 images (about 500*500 pixels), and someone uploads another picture, what is

5条回答
  •  攒了一身酷
    2021-01-20 22:02

    The system should just be able to filter out images that are excactly the same.

    In that case you could simply forget that you're talking about images and just treat them as binary files, using hash_file() to create a hash.

    Of course, this would also result in different hashes for images that differ only in metadata such as EXIF comments in JPEG images. You'll have to decide whether that's a problem for you.

提交回复
热议问题