Weird results using PHP-Imagick getImageSignature method

[亡魂溺海] 提交于 2019-12-25 03:47:05

问题


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?

Thanks a lot.


回答1:


Should I always get the same signature in these conditions?

Short answer is no.

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.

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());
 }
}


来源:https://stackoverflow.com/questions/25119285/weird-results-using-php-imagick-getimagesignature-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!