问题
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