The Blogging Technician Providing useful info for all of you and myself

17Nov/15Off

Laptop to Digital Photo Frame with Ubuntu 15.10

I decided to embark on what turned out to be quite an adventure from start to finish to build a Digital Photo Frame from an old laptop I had laying around. I will add photos later but the meat and potatoes of the project was the apache2 and Flickr API integration, which is what I will be covering here. I found an amazing site that contained a great tutorial with most of the information I needed at Burgerfaire.com their software build was up to Ubuntu 12.04 as of this writing which led me most of the way but with a few issues I hope to clear up here. So here it goes....

I have a working Ubuntu 15.10 install, 4GB ram, 250GB HDD.

The first thing burgerfaire recommends is to install SSH.  as the GUI on older laptops can be a little resource heavy, causing the laptop to feel sluggish, instead of an old laptop with a lighter more responsive operating system.

Getting Started with ssh (if just using the GUI skip ahead to Configuring the System)

Login to the GUI, go to the ‘Dash Home’ and in the search box type  terminal

Choose the termial app of your choice.

In the terminal window type: sudo apt-get install ssh

enter your password…

wait for ssh to install after which terminal will return to waiting for input.

Configuring the System

Still in terminal type: ifconfig

Ifconfig will give you your IP address so you can use putty or something like it to SSH into your frame (if desired otherwise continue using terminal)

Once you are in, the basic setup is the same between ssh (if applicable) and terminal, let’s take a look at that…

sudo apt-get update

This will make sure your source packages are up to date.

sudo apt-get upgrade

This will make sure you have the latest packages installed.

Next, install all of the packages that make the backend, frontend, and black magic work.  After all, this is black magic to most people.

Feh is the actual slideshow program.  It displays the directory of files for you in the display.

sudo apt-get install feh  

Graphicsmagick is the program we use to generate the slides for weather, news, scores, etc….  You will only need this for the ‘extra’ stuff at the end of the tutorial.  You don’t need it to run the pictureframe for flickr photos etc…

apt-get install graphicsmagick 

Make is necessary to ‘make’ various modules, it is required, so is gcc.  Install them both.

apt-get install make gcc 

Apache2 is the webserver used to configure the slideshow content and set up the authentication with flickr.  It is required.

apt-get install apache2 

Perl is the language the FlickrFrame script runs with.  it is required.  Also the www libraries for perl, and the apache mod for perl(I know that seems greek to some, just do it.)

apt-get install perl libwww-perl libapache2-mod-perl2

Here is where things got a little different with 15.10. You will also have to install the zlib libraries.

apt-get install zlib1g.dev

If that does not work then use

apt-get install zlib1g.devel

Once the above has been completed open a web browser and type in your IP address (if SSH)  or 127.0.0.1 (loopback if terminal).  You should see an apache2 page that says, “It Works!”

The FlickrFrame script

Get the file from sourceforge here

or use wget to get it directly

wget http://sourceforge.net/projects/flickrframe/files/flickrframe/0.9.5/flickrframe.tar.gz/download

Once you have the file, unzip it.

tar -xvf flickrframe.tar.gz

Or if using Package Manager within Ubuntu 15.10 extract the contents to /home/username/flickrframe (replace username with your account name)

Also a little different in my experience first I had to install the module CPANMINUS using CPAN then we install the perl modules to support the flickrframe app using cpanm.

cpan APP::cpanminus

This will install and configure cpanminus

First we will need XML::LibXML and XML::Simple

cpanm install XML::LibXML

then XML::Simple dependencies

apt-get build-dep libxml-parser-perl

then XML::Simple

cpanm install XML::Simple

Now for the perl modules required for Flickr app

cpanm install Flickr::API

cpanm install Getopt::Compact

cpanm install Text::Table

cpanm install Math::BigInt

Configure Apache2

So now we get to configure the webserver for our config site.

sudo pico /etc/apache2/mods-enabled/mime.conf

find the line that says ‘# AddHandler cgi-script .cgi’ and modify it to:

AddHandler cgi-script .cgi .pl

So essentially we removed the "#" and added .pl to the end

This will add perl script (.pl) cgi support and enable .cgi script support outside of the cgi-bin directory
Ctrl -x to exit select y to save.

sudo pico /etc/apache2/sites-enabled/000-default.conf

Change the line for  Document Root to reflect the root directory of flickrframe:

from:
Document Root /var/www to:

DocumentRoot /home/username/flickrframe/htdocs

And below that add

<Directory /home/username/flickrframe/htdocs>

AllowOverride None

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Require all granted

</Directory>

Exit out using Ctrl+X and Y at the prompt to save.

Now add the localhost to the config file by opening the apache2.conf file

sudo pico /etc/apache2/apache2.conf

In the following to the section starting at line 147 (#Sets the default security model of the Apache2 HTTPD Server...) below the code for

<Directory /var/www/>

...

</Directory>

Add

<Directory /home/username/flickrframe/htdocs>

Options Indexes FollowSymLinks ExecCGI

AllowOverride None

Require all granted

</Directory>

Add the following line to the bottom of the file

ServerName localhost

exit and save

Restart apache2 and watch for errors

sudo service apache2 restart

This should return without errors.

Configure FlickrFrame

Copy the config file from the source…  Go to the flickrframe directory.  Then copy the file to keep the original intact for reference.

cd /home/username/flickrframe
cp flickrframe.conf.dist flickrframe.conf

Change permission on the file

chmod 666 flickrframe.conf

Permissions are touchy, but this has always worked for me, so far.

chmod 774 Flickrframe.pm
chmod 774 htdocs/ff.js

Configure Image Folders

Create a  directory as a subdirectory of your /home/username/flickrframe/Pictures folder so you can still use local folders i.e. /home/username/pictures for pictures you don’t put on flickr. This is due to the fact that any photos not part of the sync will be deleted from the subdirectory.

cd /home/username/flickrframe/Pictures
mkdir ffimage

Authorization with Flickr

This part always seems to take longer than you think.  I think we are so used to getting quick gratification, that when this doesn’t work exactly right, we (I) get confused.

Open your Web Browser and go to your IP address:

http://whatever.your.IP.Address/authwizard.pl

This will allow you to set the synchronization portion for flickr.  The process here is to set up the API key to use your flickr account.  You will need to login to your flickr account and request a key… the instructions are on the web interface for your digital picture frame.

The authorization script will ask you to add the key, the shared secret, etc… after you set that wait about 5 minutes. then click the link to authorize everything.

This will take you to the configuration for the slideshow.

Just to make sure everything is working correctly,

choose “Interesting”
set the Max to 10
Check “Shufffle”
Display interval to 10 seconds
update to 120 Minutes
Image folder to where you created the ffimage directory above.
Log file to /home/flickrframe/fflog.log
click save

Now back to the terminal to start the backend sync process…

/home/username/flickrframe/FlickrFrame.pm -b -c /home/username/flickrframe/flickrframe.conf

..wait a few minutes… check the log file.

Here is what my log file looked like….

Sun Sep 30 13:18:39 2012: Starting Backend
Sun Sep 30 13:18:39 2012: Getting interesting photos
Sun Sep 30 13:18:42 2012: Online Photosets have 10 photos
Sun Sep 30 13:18:42 2012: Storing http://farm9.staticflickr.com/8318/8033186169_089904b9d1_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:42 2012: Storing http://farm9.staticflickr.com/8029/8035121653_cedc58cfd5_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:42 2012: Storing http://farm9.staticflickr.com/8042/8036054937_ae14a03cc7_o.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:42 2012: Storing http://farm9.staticflickr.com/8176/8035054900_fb414c4cf7_o.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:43 2012: Storing http://farm9.staticflickr.com/8039/8036235451_7347cf1b7d_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:43 2012: Storing http://farm9.staticflickr.com/8457/8029082356_639585b652_b.jpg as /home/flickrframe/Pictures/ffimages/802$
Sun Sep 30 13:18:43 2012: Storing http://farm9.staticflickr.com/8039/8035261504_f85259511b_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:43 2012: Storing http://farm9.staticflickr.com/8039/8035461333_f62d8ddedf_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:43 2012: Storing http://farm9.staticflickr.com/8455/8035673550_ccf96ec253_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:44 2012: Storing http://farm9.staticflickr.com/8035/8035118437_f9a2f107d1_b.jpg as /home/flickrframe/Pictures/ffimages/803$
Sun Sep 30 13:18:44 2012: Restarting FlickrFrame Frontend
Sun Sep 30 13:18:44 2012: Killing fbi:
Sun Sep 30 13:18:44 2012: Synchronization Complete

You can now check your image directory to see if you see any images…

ls /home/username/flickrframe/Pictures/ffimages