简体   繁体   English

将二进制JPEG图像数据加载到PHP变量中以进行MD5哈希处理

[英]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. 我正在编写一个PHP脚本来验证两个文件中的JPEG数据是否相同。 The EXIF/IPTC (metadata) may change between the two files. EXIF / IPTC(元数据)可能会在两个文件之间更改。

My general approach is to use an MD5 hash to compare the binary JPEG data of the two files to confirm it's unchanged. 我的一般方法是使用MD5哈希值比较两个文件的二进制JPEG数据,以确认其不变。

However, no matter what I do using GD, I seem to be getting an MD5 hash of BOTH the metadata and JPEG data. 但是,无论我使用GD做什么,我似乎都同时获得了元数据和JPEG数据的MD5哈希。 Does anyone know the best method to extract just the image data from a JPEG file using PHP? 有谁知道使用PHP从JPEG文件中仅提取图像数据的最佳方法?

Thanks in advance... 提前致谢...

@jarek.d above suggested using mogrify (part of imagemagick), so I am using exec to strip the metadata before comparing the two files. 上面的@ jarek.d建议使用mogrify(imagemagick的一部分),因此在比较两个文件之前,我正在使用exec剥离元数据。 This works well. 这很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM