PNG Hit Counter

pngcouter is a website hit counter that generates PNG images instead of GIF's. It is released under the GNU GPL and can be freely distributed and modified according to the terms of the GPL.

I wrote pngcounter because I couldn't find a free hitcounter that I liked. Most of the counters I was able to find were from one of several companies and could only be used on the condition that you have a link to their site accompaning the counter and that you give them more marketing info than I cared too. The other options were very basic Server-Side-Includes that other people wrote. These didn't do what I wanted, and several were riddled with security holes.

So I decided to write my own, and while I was at it, I decided to break away from GIF counters (do to the patent issues) and write a counter that uses PNGs for its input and output format.

Each counter consists of just two files (a count/style file and a log file), which are updated by the pngcounter program and used to produce the image sent back to the browser. Creating a new style for the counters to use is as simple as creating 12 PNG images (digits 0-9 and left and right edge pieces), and then adding them to the pngcounter's data directory.

The program is also very flexible since every counter that pngcounter maintains can have a different style and padded length, which are individually configurable by that counter's owner from the web based control center (control center is still being written).

The latest stable releases of all package files and other project information are always available at

The sources to pngcounter and some hit-counter styles I have made for use with the counter are available for download at the site mentioned above. My styles are not necessary to use the counter, but if you don't download them, you will have to create your own styles for the counter to use.

I've tried to make pngcounter as secure as possible, but it's entirely possible that I may have overlooked something. If you find any potential security holes, please let me know so I can fix them. You can reach me at

Know Bugs and Limitations (ie. If you want to help, I'd appreciate it)

The input PNG files must currently by "flattened" (for example: layers->"Flatten Image") in the GIMP. Otherwise the output image isn't generated quite right. I taught myself the basics of the PNG libraries, but don't fully understand some of the more advance aspects of the image conversion/loading options yet. If the output image is elongated with colored bars in it, this is the source of the problem.

The web-based control center in the tarball is still being written, and should NOT actually be used on a website yet. It is for demonstration purposes only. At this point, only some of the necessary functions have been written. Until this is done, there will be instructions in the README on how to manually set up counters.

I'd appreciate another set of eyes to look over my code and make sure I didn't leave any security holes open.

 Other Software I've Written