使用PHP-Imagick getImageSignature方法的奇怪结果 [英] Weird results using PHP-Imagick getImageSignature method

查看:126
本文介绍了使用PHP-Imagick getImageSignature方法的奇怪结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP Imagick的getImageSignature方法来比较不同的图像并查看它们是否相等,但是当从不同版本的不同计算机调用该方法时,即使使用相同的图像文件,我也会获得不同的签名ImageMagick和OS。

I´m trying to use PHP Imagick´s getImageSignature method to compare different images and see if they are equal, but I´m getting different signature even with same image file when the method is called from different computers with different versions of ImageMagick and OS.

在这些情况下,我是否应始终获得相同的签名?

Should I always get the same signature in these conditions?

非常感谢。

推荐答案


我是否应该在这些条件下获得相同的签名?

Should I always get the same signature in these conditions?

简短回答是否。

Imagick :: getImageSignature 包裹 MagickGetImageSignature ,它在内存和运行时基于运行时的虚拟像素生成签名。量子色空间。后者受编译时的配置选项或环境参数的影响。版本和主机架构的差异将导致图像签名的变化。

The Imagick::getImageSignature wraps MagickGetImageSignature which generates a signature at run-time based virtual pixels in memory & Quantum colorspace. The latter being influenced by the configuration options at compile time, or environment parameters. Differences in versions, and host architecture will contribute to the variations of the image signature.

由于签名只是SHA-256摘要,因此生成一个更简单你自己。

As the signature is just a SHA-256 digest, it would be simpler to generate one yourself.

$signature = sha1($image->getImageBlob());
// or subclass the method
class MyImagick extends Imagick {
 public function getMyImageSignature() {
   return sha1($this->getImageBlob());
 }
}

这篇关于使用PHP-Imagick getImageSignature方法的奇怪结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆