andrewniesen
andrewniesen

Reputation: 394

Load binary JPEG image data into PHP variable for MD5 hashing

I am writing a PHP script to verify that the JPEG data in two files are identical. The EXIF/IPTC (metadata) may change between the two files.

My general approach is to use an MD5 hash to compare the binary JPEG data of the two files to confirm it's unchanged.

However, no matter what I do using GD, I seem to be getting an MD5 hash of BOTH the metadata and JPEG data. Does anyone know the best method to extract just the image data from a JPEG file using PHP?

Thanks in advance...

Upvotes: 0

Views: 159

Answers (1)

andrewniesen
andrewniesen

Reputation: 394

@jarek.d above suggested using mogrify (part of imagemagick), so I am using exec to strip the metadata before comparing the two files. This works well.

Upvotes: 1

Related Questions