Page 2 of 212

Dynamic Galleries and Random Images for WordPress Photoblogs

I was looking for ways to optimize my website . . . to make it quicker and easier for me to maintain and update, while being fun to browse for my visitors. The problem with the old gallery and random photos at the top of each page, was that I had to make the thumbnails and update the page and database for both (I was using the this randomizer plugin for WordPress), each time I added a photo. It was good because I’d crop, scale down, and sharpen each image to look its best, but the extra work was too much. I found the Post Thumb plugin is the perfect solution. I installed it, set it to make 100×70 thumbnails, and then added this code to my blog header:

<?php the_random_thumb(“link=p&limit=5&category=8″); >

That makes it show five random photos from the category for my photos, linking to the page for each instead of the file. The great thing here is that the thumbnail folder and accompanying MySQL table is updated automatically, so photos are added to the pool as soon as I publish them. A random photos section is good for the casual browser, who just looks at what catches his eye.

Next, I wanted to create a dynamic gallery and random image page. I added the Exec-PHP plugin so I could use PHP code in pages and posts, but found that WordPress inserts a line break between each thumbnail, against my wishes. For that, I added this modified version of Text Control by Jeff Minard, then setting it to not auto-format the gallery and random pages.

The code for page one of the gallery is:

<?php the_recent_thumbs(“subfolder=g&width=200&height=160&link=p&limit=60&category=8″); ?>

and for page two:

<?php the_recent_thumbs(“subfolder=g&width=200&height=160&link=p&limit=60&offset=60&category=8″); ?>

The parameters with all the ampersands tell the script to make 200×160 thumbnails instead of the default, to save them in a subfolder named “g” (for gallery of course), to link to the posts the photos are in, to display sixty thumbnails per page from category 8 (my photos), and, on the second, “offset=60″ means to start with photo #61 (computer programming languages count from zero). When I get over 120 photos (I’m at 83 now), I’ll have to make page three manually. I don’t mind that, since mine is a low-volume photo-blog focusing on quality, so I’ll only need to make a new page every few months. I’m stoked enough by what can be done without my help.

Next up was the random page:

<?php the_random_thumb(“subfolder=g&width=200&height=160&link=p&limit=24&category=8″); ?>

This is almost the same as the first gallery page; the function is the_random_thumb instead of the_recent_thumbs, and I reduced the number of photos from 60 to 24. It worked great, except the random photos would not be refreshed on each visit to the page. The problem was the caching module I use, WP-Cache, so I solved it by adding “/random” to the list of rejected URIs in its settings. Unfortunately, this makes the random page the most computationally expensive on the site, which is especially a concern because I’m on cheap, shared hosting. I’ll keep an eye on it, and if it gets too popular and things start crashing, I’ll reduce the number of images or pull the plug.

As if this wasn’t enough, I had another feature to add: a link to a random photo for sale in my expensive shop (powered by YAK), at the top of the sidebar on each page. After doing the above, this was easy:

<?php the_random_thumb(“subfolder=s&width=128&height=86&link=p&category=389″); ?>

This time, there is just one thumbnail per page, so “limit=” is omitted (it defaults to 1). The subfolder for the thumbnails is “s” for shop; you can make the subfolder’s name longer, but I’m keeping it short for simplicity. The width and height are different to match the size of my sidebar , and the category is #389, to show only posts from my shop for framed prints. I’m letting WP-Cache in place, but it clears every day (a.k.a. 86400 seconds), so each page will show a different print each day.

Is that enough? No, Post Thumb isn’t done helping me. I normally create the thumbnails and HTML code showing them for each photo, but the plugin can take care of that automagically. I made these choices in the settings:

Alakhnor's Post Thumb auto-thumbnail settings

For the screen capture of the settings you see above, I added the rel=”nothumb” tag after the alt text, because it’s 475 pixels wide, so resizing to 400 isn’t needed. But I’ll be letting it auto-thumbnail most of the time. For Sunrays 3, for example, I would normally make a thumbnail, upload it, and write this HTML for the post:

<a href=”http://thripp.com/files/photos/sunrays-3.jpg” title=”Sunrays 3 — orange rays of sunshine pierce black clouds”><img src=”http://thripp.com/files/photos/sunrays-3-sm.jpg” alt=”Sunrays 3 — orange rays of sunshine pierce black clouds” /></a>

But now, I write this:

<img src=”http://thripp.com/files/photos/sunrays-3.jpg” alt=”Sunrays 3 — orange rays of sunshine pierce black clouds” />

. . . and the plugin resizes and saves the photo, uses the new version as the image, links to the full-size version, and specifies my alt text as the hover title, while showing the abbreviated code when I return to edit the post. And this is all done before sending it off to LiveJournal and Xanga (with LiveJournal Crossposter and Xanga Crosspost). Very cool, and better than what WordPress does out of the box.

Post Thumb finds the first image in a post, then using a thumbnail of it to represent that post. Since I only put one photo to an entry, it’s perfect in my case. I have both the convenience of a photo-blog and the versatility of a text blog. I can write text articles like this one right alongside my photos, both show up to my RSS and email subscribers, and I can include lengthy descriptions for my photos, while WordPress and Post Thumb do the heavy lifting to compile a detailed blog and minimalist gallery. This is more than can be said for WordPress 2.5′s built-in galleries, or the add-on solutions. It is much preferable for teaching galleries like my own, with lots of text and information accompanying images, than for people who just want to put up scads of photos with no details. I use Gallery2 for the scads of photos (my gallery is private). WordPress and Post Thumb bridge the gap.

While I was at it, I switched default fonts on the site from Lucide Grande to Arial, because it’s included with Windows, and renders better at small sizes in Firefox. I also changed the banner from olive green to a powerful black. The last step was to add links to the new gallery pages below the banner. Changes are good.

Low-Light Photography on your Digital Compact

Low Light — Photo by Richard X. Thripp

Peter Rise has an interesting question for me:

“When you’re doing action photos, do you use the viewfinder, or an LCD display that you can look at from a distance? What are the advantages/disadvantages for each?

I ask because I’ve been *attempting to* take school basketball pictures lately, which I find extremely difficult. Much more difficult than football or wrestling photos, because basketball is much faster-paced. The ball typically switches players within 1-2 seconds, and by the time I find a good photo, they’re on the opposite side of the court. If you could think of any advice that might be helpful, I’d really appreciate it.”

I use the viewfinder, but I have a digital SLR, where you can’t use the LCD screen anyway. On my smaller Canon PowerShot A620, I have both, but I generally use the LCD, to avoid the parallax error, which is quite bad on my camera, even at far distances. If you notice the LCD screen lagging in low light, the viewfinder is better.

Of course, there is then the issue that point-and-shoot cameras don’t operate well without a flash indoors (even if it’s fairly bright). Have you ever noticed at the basketball game, or any indoor performances, that people from 40 feet away have their flashes flashing away? The flash will do no good at that distance, and they’ll get grainy, under-exposed shots and be disappointed. This is due to two problems: one, they have their cameras set to an automatic mode, and the camera does what it thinks is best, which is in this case, horribly wrong (no flash is the only way to go beyond about ten feet). Two: compact cameras have small sensors that do a poor job at gathering light compared to SLRs. I struggled with this problem for two years before getting a Canon Rebel XTi last August, and found the following options:

1. Use the largest aperture setting (lowest F number), though this won’t be enough alone.
2. Increase your camera’s light sensitivity (ISO speed), though this produces grainier photos (digital noise).
3. Use a tripod, hold really still, or brace the camera against a hard surface such as a chair, table, or wall. Get your subjects to hold still too, though this is not an option at a basketball game, of course.
4. If you can’t do 3, use image stabilization, though you’re out of luck if your camera lacks the feature.
5. Go into manual mode and use a faster shutter speed, deliberately under-exposing your photos, and then brightening them on the computer afterwards. This is a bad option, as it lowers the quality your photos’ quality on many levels: shadow detail is lost; posterization and JPEG compression artifacts become noticeable. It won’t be so bad if you use RAW mode, but if your camera offers RAW mode, it’s probably high-end anyway, and you won’t need this kludge.
6. Take three or four photos where you normally would’ve taken one. You’re likely to get one sharp photo, even with a 1/20 shutter speed.
7. Zoom out all the way, because zooming in magnifies camera shake resulting in photos that are more blurry.

Use 1, 2, 3, 6, and 4 (image stabilization) if you have it (but not on a tripod), and you’ll have a winning combination. 7 works if you have to balance the camera yourself, but you’ll include a lot of clutter and barrel distortion may become noticeable.

For the technical details, use “Sports” mode, or if you have an Aperture Priority mode on your camera, switch to it, raise the ISO speed up to 400, and change the F number to the lowest setting (2.8 on my Canon PowerShot). If the photos are still blurry, raise the ISO speed to 800 (if available), or use a tripod or equivalent.

Even after doing all this, you’ll still have the problem of shutter lag. You press the button, and then 2 seconds later, after automagically choosing focus, aperture, shutter speed, white balance, and the flash to use, the camera takes a photo of the empty side of the court. The biggest thing you can do to combat this is to have the camera make these settings in advance, and this is accomplished in almost every camera by pressing the shutter button down half-way, holding it, and then finally pressing it down all the way at the right moment. Keep in mind that your locking in the settings with the half-click, so if you do it on the dimly lit edges of the court and then move to the bright center, you’ll get a photo that’s too bright, and moving close-to-far or vice-versa will merit an out-of-focus image.

If it’s really dark, you’ll have to manually focus the camera. Many compacts don’t offer this, so try locking the settings with a half-click, pointing toward a bright object that is as far away as your darker subject.

If you’re looking for a camera for ambient-light photography, but don’t want to invest in a good digital SLR ($450 for the Canon Rebel XT on Amazon.com), the Panasonic Lumix DMC-LZ6S ($120) and Fujifilm FinePix F40fd ($184) are getting good reviews.

If you are going to be using the flash, 7 Strategies for Avoiding Flash Blow Out at Digital Photography School complements this article.

I took the photo at the top in a dimly lit theater, with a Fujifilm FinePix A360 digital compact (more photos) in auto mode with the flash off. 1/2 shutter speed, ISO250; had to brace the camera on the seat in front of me.

Keywords: low light, ambient light, lighting, dark, indoors, basketball court, flashless photography on the cheap, sensors, iso speed, shutter lag, how-to, suggestions, digital compacts, digital point-and-shoot cameras, p&s, a beginner’s guide

8 Tips for the On-Cue Photographer

Be prepared. — Photo by Richard X. Thripp

I was reading 5 Reasons to Take Your Camera Everywhere in 2008 over at the Digital Photography School Blog, and it really resonated. You need a camera with you to take any sort of photos—this is a point that is not stressed enough in photography guides and classes. I’ve produced my best work on outings not intended for photography: Sky of Fire, Two of Us Against the World, and Sky’s Camouflage, for example. The article is good, but I want to add eight tips so that once you have your camera with you, you’re ready to use it:

1. Leave the SLR at home. Get a small point-and-shoot (P&S) camera so you aren’t loaded down. Make sure shutter lag is slim to nil; the venerable Canon PowerShot A620 (photos) has been in my pocket since 2006, though it’s harder to come by as its gone out of production.

2. Keep one, versatile lens. While this contradicts the above tip, there are some situations where you’ll need an SLR. P&S’s aren’t typically suited for low-light, so if you’re out in the evening or anywhere indoors, where P&S’s can’t work with the ambient light, take an SLR and a fast lens. My choice for such situations is the Canon EF 50mm f1.4 (photos); open the aperture and crank up the ISO speed, and you’ll be able to hand-hold without a flash even for night-time street photography. Then there is bright mid-day, where a slower, zoom lens will be your best bet. I still use the Canon Rebel XTi kit lens (photos); it’s a good start for wide-angle photography and produces sharp photos at f/8.

3. Drop the camera bag. While a bag for your lenses is acceptable (though picking one lens will save weight), your camera needs to be at the ready for baby Lucy to skip through those mud puddles. I’d never be quick enough to get the shot at the top of this article with my camera cooped up in a cozy bag. If you have a P&S, stow it in your pocket, or sling an SLR around your neck.

4. Freshly charged batteries are a must. Murphy’s law states that your batteries will fail just when you need them the most.

5. Have space for 100 photos on your memory card. While you may not capture that many brilliant photos, you won’t have time to swab the decks when that seagull grabs the fish, or those clouds form your Aunt Mary’s face. With the burst modes on modern cameras producing three photos a second, you’ll want plenty of temporary space for crazed snapping.

6. Set your camera. That 15-second exposure with tungsten white balance won’t cut it for a spontaneous afternoon portrait. Set your ISO speed, white balance, and flash preferences, then choose your aperture or shutter speed in the priority modes, and have the camera take care of the rest. If you’ve forgotten to do this, dial in Auto mode real quick for that fleeting Kodak moment; sub-optimal results are better than an over-exposed, blue mess. Use RAW mode for editing leeway, though note that the larger file sizes will slow you down from shot-to-shot.

7. Brace yourself. Blurry photos of your precious moments are no fun. Turn up the shutter speed as much as you can; the same as your lens’ focal length at minimum (i. e. 1/50 second for the EF 50mm f1.4, or 1/80 on the XTi because of the crop factor). Hold still, keep the viewfinder glued to your face, and support the lens barrel with your other hand while you click three shots, then delete all but the sharpest. If you have a P&S, don’t keep it at arm’s length as you’ll shake the camera more.

8. Turn off auto-focus. Even on SLRs, auto-focus causes the biggest delays from click-to-shoot. If your subjects will be consistently far from your camera, lock in the focus and switch to manual mode, then enjoy the lightning-fast shutter lag. Alternately, half-click your shutter button a few seconds in advance and hold it—then when you push down all the way, you’ll get a quick photo with the settings the camera locked in.

Photography is as much about skill as it is being in the right place at the right time. When life’s picture-perfect moments pop up, be sure to have your camera at the ready.

On Exposure

One thing about digital photography, a short-coming compared to film, is that you can’t recover from over-exposure (except somewhat using RAW format). So be sure to get it right the first time, because you can’t edit the detail back in. Note that in that photo, the white highlights in the sky aren’t actually clipped (if they were “clipped,” they’d be pure white), but if your monitor is too bright, you won’t be able to tell by sight. Same goes for you camera’s LCD screen. This is why you have the histogram (hopefully, anyway; I used to have a Fujifilm A360 camera that completely lacked it). If the bars trail off to the right, you know your photo has pure white areas (over-exposure), and if it continues to the left, you have pure black areas (under-exposure). If it does both, as it often will during mid-day, there is too much contrast in the scene. Usually, clipped shadows, like the ones in the black areas here, are more pleasing than clipped highlights. The sun (below) is an exception, as we expect it to be bright (same goes for the sky, but not in sky-centered photos like sunsets). The photo also has clipped shadows (the flower buds on the left), but it looks nice still. However, I increased the contrast carefully on the computer (the second image is the original); it wouldn’t look that good straight from the camera.

Yellow Sunshine (edited) Yellow Sunshine (source image)

Page 2 of 212