The Snapshot function – saving mosaics as images
March 15th, 2006 in The Making of TheBroth · By Markus WeichselbaumOne of the first cool features that we were eager to implement was a snapshot function, so we could preserve the transient masterpieces that were being created in front of our eyes.
The GD library for PHP makes this task easy. We’re creating a full-size image by simply “painting” the position of the tiles onto a blank canvas, and saving the image to disk. The thumbnail image is created using GD’s resize function, and also saved to disk.
Haven’t seen the snapshots yet? Go visit TheBroth’s art gallery!
Why PNG format?
We decided on using the PNG format (PNG-24, to be specific) for the snapshots, as this produced images with the smallest file size, yet yields much better quality than the JPEG format. This isn’t surprising, as snapshots of TheBroth mosaics aren’t really photographic in nature. The snapshots are more like “graphics”, with flat colors and plenty of blank, fully white background, and images of this type can be saved economically in PNG format.
Unfortunately, the thumbnails don’t look good in either format, but here JPEG files were smaller, so that’s what we use for the thumbnails.
Why not GIF? Because just like PNG-8, it allows for only 256 different colors, unlike JPEG and PNG-24 which are true color (eg. full 24 bit color) formats.













