thefoggiest.dev

Scry

Whenever I do something or go out with family or friends, I usually take lots of pictures. And so do they, at least some of them. Afterwards, we are often interested in each other’s pictures, so I usually collect them all to show them to everyone. But that is easier said than done. I have tried emailing zip files, but that is too cumbersome. Even when everybody’s email box will accept large files, the concept of unzipping files appears new and painful to most people.

Given the fact that I have my own web server, the solution is pretty obvious. Now there are lots of scripts available that will publish pictures on a web page, but most are way too bloated for my purposes, and with bloatware comes tiresome maintenance. I’ve tried Zenphoto for instance, because it allegedly integrates well with WordPress, which is the script behind this blog. It didn’t, and I had to invest way too much time to find out it couln’t do what I wanted.

Enter Scry, a small collection of php scripts with the tagline:

Scry is the simplest PHP photo album you’ll ever love.

It really is. It doesn’t need a database, has no admin interface, doesn’t allow naming pictures or comments and won’t let you manually reorder them (as if I would ever want that). But it is very simple, elegant, and most importantly, predictable. There are a few configuration options (how many thumbnails per page, which directory contains the collections) which are set in one of the PHP files itself.

Scry needs a directory in which directories with pictures can be placed. Every collection goes into its own directory, and you can group collections into super collections as much as you want. I have grouped collections per year, because I find that useful. The only thing I had to do was create the directories and move the right directories to them. Scry scans the directories and shows the pictures, recursively.

When a visitor navigates to the site, the first thing she sees is the top level directories.

When a directory contains pictures, these are shown as thumbnails.

When a thumbnail is clicked on, it is shown big, with below it some EXIF meta data (using a plugin called Exifer)  and the thumbnails of the previous and the next picture in that directory, which can be clicked to navigate.

Apart from the easy maintenance, I really like the clean and straightforward layout. Everything is clear, nothing is obscure or confusing. The script shows pictures. That’s all it does, but it does it well.

The pictures do need a little processing before they can be published using Scry, though. First, I want my pictures ordered by the time they were taken. But since my collections contain pictures from different camera’s with different file naming schemes, I need them ordered by the timestamp value from the EXIF meta data. I also take lots of pictures in portrait orientation, so pictures must be rotated correctly as well. This information too can also be found in the EXIF meta data.

Scry, like Zenphoto, doesn’t do any ordering or EXIF rotation. But since Scry doesn’t use a database, the ordering is naturally done by filename. So all I need is to take the time stamp values and prepend them to the file names. The pictures will then be ordered by time. jhead(1) Can do that:

# jhead -n%Y%m%d%H%M%S_%f *jpg

This will change any picture whose filename ends with jpg from something like img0129.jpg into something like 20110101120000_img0129.jpg.

jhead Can also rotate images:

# /usr/bin/jhead -autorot *jpg

This will correctly rotate any picture whose filename ends with jpg, including any embedded thumbnails, adjust the width and height values and remove the orientation value from the meta data. That last thing is important, so EXIF-rotation aware programs won’t rotate the picture any more.

I also don’t publish full 11 mega pixel images over the web, so I always downsize the images, using ImageMagick‘s mogrify:

# mogrify -scale 25% *JPG

It’s things like this that show the command line’s superiority to any GUI: even if your collection contains thousands of images, you just need these three commands to order, rotate and shrink them all.

When you go to the Scry website, it appears that Scry is not very much maintained at the moment. The latest news is the announcing of version 1.2 on 15 July 2006, which is some time ago. Scry has few dependencies however, and seems to work without issue on my Arch Linux server which I update weekly.

UPDATE: Actually, Scry does have one issue. When installing Scry on a server with PHP 5.3.0 or later installed, you’ll notice you’ll get deprecation warnings. Scry makes use of eregi. The easiest work-around is putting an ‘@’ sign in front of every eregi function call, like this:

...
if (@eregi("^" . rtrim('/', $test) . ".*", rtrim('/', realpath($victim)))) {
...

(line 34 in functions.php)

You will find them in functions.php and view.tpl in the default template, as well as exif.php if you install the exifer plugin (see below).

UPDATE2: It appears ‘m ┬ánot much of a PHP wizard. Using the solution above will make the warnings disappear from the site, but not from your logs. That means one warning message per request, which is every time someone clicks anything on your Scry site. I have therefore submitted patches to Scry that replace all eregi and eregi_replace calls with preg_match and preg_replace calls. Since the Scry CVS is unreachable, you will find them on the feature request page.


Categorised as: cool stuff


One Comment

  1. […] I wrote about Scry, a PHP photo publishing script that I basically like for the same reasons I like my favorite Linux […]