How do I unittest an HTML page that contains an embedded dynamic image?

I've got an dynamic HTML page that contains a QR code that is generated dynamically and embedded using <img src=data:image/png:....>
. I had been testing the page by generating it with specific arguments and verifying that it matches the output I expect.
I'm now discovering that the embedded image is not as fixed as I expected. The PNG format uses zlib compression, and for Python12.3, and Windows and Linux are using different versions of the zlib library. (1.2.13 and 1.2.11, respectively). I have two correct but different compressions of the identical source bits, and the resulting PNG representations differs. The resulting dynamic page now longer matches exactly the output I expect. (The windows version now compresses to a few bytes shorter.)
I can easily verify that both pages contain the identical source, except for the images. Is there a easy way of taking the byte strings that are the PNG representation of the generated image and the image that I expect and confirm that they are the same?
Answer
Read more is a set of image manupulation utilities, including pngtoppm, which converts a png image to the raw, uncompressed ppm format. You can use that to see whether two png images are the same or not.
Enjoyed this article?
Check out more content on our blog or follow us on social media.
Browse more articles