简体   繁体   中英

Weird results using PHP-Imagick getImageSignature method

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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