Igor's Blog

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/.


, , ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume


RSS Feed

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

Recent Blog Posts

WebLogic package-name element classpath generator script

Using Jersey 2.x as a shared library on WebLogic 12.1.2

Google DFP with AdSense fallback is causing infinite scroll pages to go haywire

Workaround for Mobile Safari scrollTop() not updating during scroll

Skipping execution of Maven plugins that do not have a native skip option

Unmarshalling an XML fragment representing a JAXB object without XmlRootElement

Injecting a ContainerRequestContext into a Jersey entity provider class

Obfuscating PHP source code with Maven and YAK Pro PO

Making use of corner shelves with easy to make slide out draws

Octotree breaks GitLab Issue Boards

Recent Galleries

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

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth


RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
...or subscribe for updates!

Don't show this again