Hash of strippedImage with Imagick differes on every run

images php coding issues or problems here.

Moderators: gesf, Michalio

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Apr 17, 2022 5:12 am


I created a small script which first copy an image, strip the Exif Data from an Image and rewrite it and then generate a regular md5_hash from it.

Well, this little script gives the same hash on almost every file. There's just one file, which returns a new random hash every time, and I simply can't find the reason why.

Here's the code:

Code: Select all

// Copy due to trim process!
$imagePath = "test.png";
copy('Skin2WithTrash.png', $imagePath);
// copy('Skin3WithTrash.png', $imagePath);

# Reduce image
$image = new Imagick(dirname(__FILE__) . '/' . $imagePath);
$image->writeImage(dirname(__FILE__) . '/' . $imagePath);

# Return hash
While the Skin3WithTrash.png returns the same hash, it varies for Skin2WithTrash.png every time.

The simple question is: Why? And how can I solved this..

All files for needed to test it are attachted.
(26.67 KiB) Downloaded 38 times
Thx for every hint and happy Easter! :-)
Post Reply