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

后端 未结 5 1719
失恋的感觉
失恋的感觉 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:00

    Byte-wise comparison of files will fail even when a small detail like a ID3 tag has changed. To compare the picture contents, you would have to open the image file and create a hash of the actual image pixel data. But even that can be undone by saving, say, a JPEG file twice with a slightly different quality level - the subtle encoding differences will create changes in the pixel colour values.

    So if you are really looking to match image contents across formats and qualities, you are opening a huge can of worms :)

提交回复
热议问题