GrViewer: Graphics Files Viewer

live demonstration
view source code or retrieve from git://


This utility provides a quick-and-dirty way to view graphical image files in a given directory. In some ways, it is similar to the "preview" mode provided by Windows and Linux graphical folder utilities, but works within a Web server environment. It is particularly handy when you have a number of graphical files with names that are not particularly descriptive.

This short standalone PHP script reads all of the files in the directory in which it resides, and those that match the specified file extensions (by default, .gif, .png, .jpg, and .jpeg) are displayed on the Web page the script generates. The extensions are defined as an array of constants at the top of the script and may be easily expanded to include other file types.

This utility is called grviewer.php, and its code is available here. If you want to see the script in action, run the script /Graphics/grviewer.php, which displays the contents of one of this site's graphics directories.

The code is well-documented and pretty simple, so customizing the script to your own tastes should be easy.

The usual personal preference disclaimers: My background includes years of programming in C, so I prefer printf() over other PHP output functions: it has powerful formatting capabilities and allows for some very compact code. Also, PHP statements in my scripts are always in their own independentally indented code blocks, as I consider PHP code placed inline with HTML content to be a debugger's worst nightmare.

SSL Certificate