Imagick Testing


I’m upgrading my software from using PHP7.4 to PHP8.0 (can’t use 8.1 yet), and a few of my tests are failing. Specifically the tests using Imagick.

I have a static sample image that I am comparing to the dynamic image the test is creating. The file is saved with the current time time() as filename. I tried running the test twice (renders two images where the only difference is the filename). I then compare the output and there’s a few bytes of differences.

The only dynamic variable is the filename, but that isn’t stored in the output(?).

Shouldn’t Imagick create identical content when called with the same variables and parameters? The tests passed previously, so it has in earlier versions. Will this constitute a bug or are there reasons why the output will differ on each call?

Apparently there’s a timestamp included in the file that causes every image not rendered at the same time to be different.

For anyone who may have the same issue, here’s how I solved it.

From this Stack Exchange thread, I found that you can strip the timestamp (and likely other things) by using an option and in PHP this option translates into the $imagick->stripImage() method. See PHP: Imagick::stripImage - Manual

Sponsor our Newsletter | Privacy Policy | Terms of Service