Igor's Blog
Programming, DIY, Games, Hacks, and Tech

A while back I wrote an entry on how to get the Lenovo LT1421 USB DisplayLink monitor working on a RaspberryPi. Now I took that a bit further and created a photo frame using the Raspberry Pi model A, a USB monitor and a bunch of software and some custom scripts.

This is part two of this blog post, if you haven't seen the first part, you can find it here: https://www.igorkromin.net/index.php/2015/04/06/raspberrypi-and-a-usb-monitor-combined-to-make-a-photo-frame-part-1/.

In the first part I got as far as setting up file sharing and disabling screen blanking on the photo frame. This post deals with the setup required for the display of the photo frame and selection of random photos from a directory. Here's a screenshot of the final result that my custom scripts have achieved:

It's important to note that the scripts assume a certain resolution for the display and may not work correctly on a different resolution. This resolution is 1366x768. So far I've not been able to figure out how to make Conky resolution independent.

I thought about how I would display the photo frame content and in the end decided that the easiest way would be to stick with Xorg and lightdm as they come out of the box with Raspbian, but I added Conky to the mix. I also decided on ImageMagick to manipulate images and threw in unclutter so that the mouse cursor would not be visible (it always gives me a chuckle whenever I see a mouse cursor on those big advert screens).

Using apt-get, I installed the following packages: conky, unclutter, imagemagick.

Once unclutter is installed, it will hide the mouse cursor automatically the next time the OS is restarted so there is no configuration required for that, however lightdm has a panel that is usually visible, this is easily hidden by editing some configuration like this:
Global {

When I first set up Conky, I was using a default font, this looked quite ugly, so I took to the web and had a look around and found a nicer font to use: Origami Mommy. It's simply a matter of copying the .ttf file to the ~/.fonts directory to install the font.

Next I set up a shell script that would select the next photo to display on the photo frame. This script picks a random photo from the /photos directory, resizes and pads the photo as needed, caches the result and copies the selected photo as /photos/caches/current.jpg. Caching is quite important because displaying large photos can take considerable amount of time on the Raspberry Pi, it also saves energy in the long run as the CPU is not being maxed out. ImageMagick is used to do the resizing and padding of the photos. The script will not pick the same photo twice in a row, so it is important to have at least 2 photos in the /photos directory or it will get stuck in an infinite loop.

Here's the script:
CURRENT_PHOTO=`cat $CACHE_DIR/current.txt`
# get new random photo
until [ $randphoto != $CURRENT_PHOTO ]; do
randphoto=$(printf "%s\n" "${files[RANDOM % ${#files[@]}]}")
# keep track of selected photo for next run
echo $randphoto > $CACHE_DIR/current.txt
if [ ! -f "$CACHE_DIR/$randphoto" ]
convert "$PHOTO_DIR/$randphoto" -gravity center -background black -resize 1066x768 -extent 1066x768 "$CACHE_DIR/$randphoto"
# swap in new photo file
cp "$CACHE_DIR/$randphoto" $CACHE_DIR/_current.jpg
mv $CACHE_DIR/_current.jpg $CACHE_DIR/current.jpg

I set this script to run every 3 minutes using cron.
 crontab -e
*/3 * * * * /photos/cache/select.sh

That's it for this post, the next post is coming soon so stay tuned. Next time around I will describe the Conky setup and will show the resource file used.

Part 3 is posted now, check it out here: https://www.igorkromin.net/index.php/2015/04/12/raspberrypi-and-a-usb-monitor-combined-to-make-a-photo-frame-part-3/.


comments powered by Disqus
Other posts you may like...

Recent Blog Posts

A hack to create an uber jar with the Maven Shade Plugin using local jar files

Is it worth it? Apple USB-C Digital Multi AV adapter vs a cheap eBay clone

Running X11 graphical applications after changing to another user using 'sudo su'

How to stop Facebook using ad images as post sharing thumbnails

Picking lists for Atari Lynx capacitor replacement kits

Performance - 2012 Retina MacBook Pro vs 2017 MacBook Pro

Look and feel - 2012 Retina MacBook Pro vs 2017 MacBook Pro

Using math to work out the diameter of hard to reach water cooling pipes

How to get the unreachable shard in the Hinterlands in DragonAge Inquisition

Measy RC12 wireless 2.4Ghz keyboard touchpad review

Recent Galleries

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Don't forget to
me for more great articles!
Don't show this again