<david.weekly.org> May 18 2008
code Pixdir: The Picture-Directory Scriptset
 
{ auf deutsch
en español
en français
}
  <d.w.o>
  about
  books
  code
  codecs
  mp3 book
  news
  pictures
  poems
  university
  wine
  writings
  video
  get my updates



don't email
"Pixdir" is the name I gave the set of crude scripts I wrote up to create the pictures section of my website. These scripts are not very elegant; at some point, I'll probably get sick of them and write something much better.

In order to use this suite, you'll need to download and install Image Magick. (Really, all I need from this wonderful toolkit is the program convert.) You'll also need to grab jhead, which allows my script to rip out all extra headers from the small thumbnails. (You want them to be a fast download!)

The main script, pixdir, is written in Perl and outputs PHP code embedded in HTML, with JavaScript snippets (just to do the popup windows). So I guess it's kind of a quad-lingual setup. It's a hack.

The script runs through the current directory and any subdirectories thereof, scouring for .JPG files. If it finds one, it will check to make sure there is a file with the same name and a more recent date in the .thumb, .thumb-small, and .full subdirectories. These three directories contain small, really small, and "fullscreen" (bounded within 300x300, 133x100, and 700x700 pixels respectively). If it does not find these subdirectories, it automatically creates them. It then spits out an "index.php" file with the appropriate HTML for a table with a small thumbnail in each cell.

There's lots of site-specific stuff in here, so if you want to make this script work for your site, you'll probably want to change it around quite a bit. (For instance, I currently have it so that when you click on a thumbnail, a bit of Javascript pops up a window that references a PHP script that displays the picture, a dark background, and a link to close the window as well as to the full-size (original) version of the photo.)

There are supplementary scripts r90 and r-90, which losslessly rotate a specified picture by 90 or -90 (270) degrees respectively. I found this handy. You will need jpegtran, but it come installed on most Linux boxes. If you don't have it, you can get it here. I found the short names handy; one window with thumbnails open, another with a shell prompt, I could whip through and correctly align my photos.

There's also a pm script, short for "picture mover", that copies not only a specified set of pictures, but also their corresponding thumnails to a destination directory. Very simple. It works like mv.

That's all. I hope this is helpful to someone. It's not teribly elegant.

  
  content & layout © copyright 1995-2008 -{ david e weekly }-