The 100 best digital picture frames on amazon
The 100 best digital picture frames on amazon
The 100 best digital picture frames on amazon
The 100 best digital picture frames on amazon

Great new fea­tures for your dig­i­tal pic­ture frame with the updat­ed Pi3D Image View­er (Nov 2019)

-

Pad­dy has done it again! My favorite Rasp­berry Pi slideshow pro­gram just got even bet­ter thanks to a num­ber of updat­ed func­tions, most notably:

  • More options to con­trol it via MQTT with Ama­zon Alexa or Home Assis­tant like paus­ing the play­back
  • Use of intel­li­gent smartlists based on the Exif data of the images
  • Auto­mat­ic refresh of the play­back list when new pho­tos are added
  • Recent­ly added images can be select­ed to be shown imme­di­ate­ly
  • Improved han­dling and auto rota­tion of images
  • Blur effect on the edges to avoid black bars when aspect ratio doesn't fit

In this arti­cle I will show you the new func­tion­al­i­ties and how to use them.

If you haven't installed Pi3D yet, please have a look at my arti­cle "How I added cross­fad­ing slide tran­si­tions to my dig­i­tal pic­ture frame using Pi3D" which explains it in detail.

How to check which Pi3D ver­sion you cur­rent­ly have

To find out which Pi3D ver­sion is cur­rent­ly installed on your dig­i­tal pho­to frame, enter in a Ter­mi­nal win­dow which is con­nect­ed to your Rasp­berry Pi:

python3 -c 'import pi3d; print(pi3d.__version__)'

If you have any­thing less than Ver­sion 2.34 you need to update.

How to update Pi3D

The update process con­sists of two steps:

Step 1 updates the Pi3D frame­work.

To do this enter

sudo pip3 install pi3d --upgrade

If you see some­thing like this

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pi3d
  Downloading https://files.pythonhosted.org/packages/ed/1e/a9ce342e89305c444494dc1be5054bc9646dc10128177f418a5f18c649ac/pi3d-2.33-py2.py3-none-any.whl (265kB)
    100% |████████████████████████████████| 266kB 1.1MB/s 
Installing collected packages: pi3d
  Found existing installation: pi3d 2.32
    Uninstalling pi3d-2.32:
      Successfully uninstalled pi3d-2.32
Successfully installed pi3d-2.33

the update will have worked.

Step 2 is about updat­ing your cus­tomized Pic­ture­Frame script.

If you already updat­ed Pi3D some­where in the past and you already have a fold­er "pi3d_demos_old" you will need to rename it to some­thing like "pi3d_demos_very_old" or delete it alto­geth­er.

Enter

wget https://github.com/pi3d/pi3d_demos/archive/master.zip && unzip master.zip && mv pi3d_demos pi3d_demos_old && mv pi3d_demos-master pi3d_demos && rm master.zip

to get the lat­est PictureFrame.py ver­sion and any oth­er updat­ed asso­ci­at­ed files.

What the above com­mand will do is to rename vour cur­rent pi3d_demos file into pi3d_demos_old and cre­ate a new pi3d_demos fold­er. This way you can always look at any set­tings in your old PictureFrame.py file.

I will walk you through the updat­ed para­me­ter sec­tion where you can enter your set­tings.

The new pictureframe.py script - The con­stants

Pad­dy has stream­lined this con­fig­u­ra­tion file and it is now eas­i­er than ever to add any user spe­cif­ic infor­ma­tion.

We'll start with the set­tings of the con­stants:

#####################################################
# these variables are constants
#####################################################
PIC_DIR = '/home/pi/Pictures/your_images/' #'textures'
FPS = 20
FIT = True
EDGE_ALPHA = 0.0 # see background colour at edge. 1.0 would show reflection of image
BACKGROUND = (0.2, 0.2, 0.2, 1.0)
RESHUFFLE_NUM = 1 # times through before reshuffling
FONT_FILE = '/home/pi/pi3d_demos/fonts/NotoSans-Regular.ttf'
CODEPOINTS = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ., _-/' # limit to 49 ie 7x7 grid_size
USE_MQTT = False
RECENT_N = 50 # shuffle the most recent ones to play before the rest
SHOW_NAMES = False
CHECK_DIR_TM = 60.0 # seconds to wait between checking if directory has changed
#####################################################
BLUR_EDGES = False # use blurred version of image to fill edges - will override FIT = False
BLUR_AMOUNT = 12 # larger values than 12 will increase processing load quite a bit
BLUR_ZOOM = 1.0 # must be >= 1.0 which expands the backgorund to just fill the space around the image

Let's go through line by line. It's eas­i­er than it first appears.

PIC_DIR = '/home/pi/Pictures/your_images/' #'textures'

Enter the direc­to­ry where your images are stored. Pi3D is recur­sive, so you enter the main direc­to­ry and all the sub­di­rec­to­ries are includ­ed.

FPS = 20

This set­ting is the frame per sec­onds speed. Whilst you can set it to 60 on a Pi 4 and to 30 on a Pi 2 and 3, I haven't noticed any increase in the smooth­ness of the tran­si­tions, so I would sug­gest that you leave it at 20.

FIT = False

"True" means that the entire image fits onto the screen and there will be gaps left (let­ter- or pil­lar­box­ing) if your image does not have the same aspect ratio as the mon­i­tor.

"False" means that the image is blown up to fill the screen there­by crop­ping parts of the image.

EDGE_ALPHA = 0.0 # see background colour at edge. 1.0 would show reflection of image

If the image doesn't fit the screen then Pi3D can mir­ror the orig­i­nal image so there is no hard edge.

Set­ting this val­ue to 1.0, it will appear, at first glance, as if the image exact­ly fits the frame. The effect can be quite stun­ning, and you often won't even notice it, but some­times it may be a bit odd.

For seri­ous dig­i­tal pic­ture frame lovers, I would always rec­om­mend to prop­er­ly crop the images to the aspect ratio of the screen. You can even use ser­vice like Crop­po­la to han­dle that task eas­i­ly.

How­ev­er, an easy solu­tion is to set FIT to False and using the mir­ror­ing that EDGE_ALPHA achieves.

So, set­ting this val­ue to 1.0 is a full mir­ror­ing, "0.0" is a black bar, and every­thing in between will reduce the opac­i­ty of this mir­rored edge.

You should def­i­nite­ly try a set­ting of "1.0" to see what the effect does and if you don't like it, you can always change it to "0.0".

BACKGROUND = (0.2, 0.2, 0.2, 1.0)

An alter­na­tive to mir­ror­ing the gaps at the edges is to give the back­ground anoth­er col­or which you can define in the RGBA for­mat.

The first three num­bers define the RGB col­or, the last one the opac­i­ty (Alpha).

I leave the (0.2, 0.2, 0.2, 1.0) default set­ting unchanged, but as all my images are cropped to the aspect ratio of the screen, it doesn't make a dif­fer­ence any­way because there is no back­ground to be seen.

In the­o­ry you could have a yel­low back­ground with e.g. (1.0, 1.0, 0.0, 1.0) but I haven't quite fig­ured out yet what use cas­es this could serve.

RESHUFFLE_NUM = 1 # times through before reshuffling

When Pi3D is launched it looks at all the images in your fold­ers and cre­ates a ran­dom playlist.

If you want this list to be reshuf­fled every time a full image cycle has been com­plet­ed, set it to "1". If you want to repeat the same ran­dom playlist sev­er­al times, set it to "x" with "x" being the num­ber of times the same sequence is being shown.

I always set it to "1".

USE_MQTT = False

If you are using Home Assis­tant or Node-Red and want to con­trol your dig­i­tal pic­ture frame from there, or you have some oth­er app that can send MQTT mes­sages, then you can acti­vate Pi3D's MQTT func­tion­al­i­ty here.

Put "True" if you are using MQTT, "False" if you do not.

If you enter "True", don't for­get to add your MQTT serv­er infor­ma­tion fur­ther below.

RECENT_N = 50 # shuffle the most recent ones to play before the rest

Pi3D will mon­i­tor your image fold­er and notice if you have added new images.

In this case, it will reshuf­fle the playlist imme­di­ate­ly so that these new images are includ­ed.

Plus, you can choose to show the most recent images first. This is very nice when you come back from hol­i­day, and every­body is eager to see the new pho­tos.

Set­ting RECENT_N to 50 will dis­play the 50 most recent images when­ev­er new images are being added.

SHOW_NAMES = False

You can dis­play the file­names of your images by set­ting this val­ue to "True". If you don't, just leave it as "False".

This new func­tion also means that you do not longer have to change the code as described in the orig­i­nal Pi3D arti­cle.

CHECK_DIR_TM = 60.0 # seconds to wait between checking if directory has changed

This spec­i­fies how often you want Pi3D to check if new images have been added.

By default, it is set to check every minute, but you can set it to 3600 if you only want to check every hour. It doesn't have a real impact on your sys­tem load, so you can safe­ly leave it at 60 sec­onds.

BLUR_EDGES = False

This fea­ture will cre­ate blurred edges to fill the screen that would oth­er­wise remain black.

You have sure­ly seen this effect when watch­ing videos that have been filmed in por­trait mode on smart­phones. As the video play­back is always in land­scape mode, two-thirds of the screen is filled with a blurred ver­sion of the video.

With images it is typ­i­cal­ly only the edges and set­ting this val­ue to "True" will cre­ate a smooth blur.

BLUR_AMOUNT = 12

This spec­i­fies the degree of blur. Set­ting it to "12" looks good, the high­er you adjust this val­ue, the more CPU pow­er your Rasp­berry Pi will have to sac­ri­fice. On the Pi 4 it's still only 5% but only an ear­li­er mod­el, it will be quite a bit more.

BLUR_ZOOM = 1.0

Just leave this val­ue at "1.0", it will expand the back­gorund to just fill the space around the image just right.

The new pictureframe.py script - The vari­ables

The new PictureFrame.py script allows you to have addi­tion­al con­trols via the MQTT pro­to­col and even to set up smart fil­ters for the play­back of your images based on the Exif date.

#####################################################
# these variables can be altered using mqtt messaging
#####################################################
time_delay = 10.0 # between slides
fade_time = 3.0
shuffle = True # shuffle on reloading
date_from = None
date_to = None
quit = False
paused = False # NB must be set to True after the first iteration of the show

Even if you are not using MQTT, you at least need to define the time_delay, fade_time and shuf­fle.

time_delay = 10.0 # between slides

How long an image is shown. I set this to 200 sec­onds.

fade_time = 3.0

As I want to enjoy the ran­dom artis­tic cre­ations of Pi3D, I set this val­ue to 10 sec­onds.

shuffle = True # shuffle on reloading

Unless you want to show your images sort­ed by name, you will want a ran­dom play­back sequence. In this case, just set it to "True".

You can change the three val­ues above by send­ing an MQTT mes­sage to your frame, which I have explained in detail for Home Assis­tant and Node-Red.

In addi­tion you can send val­ues for the fol­low­ing vari­ables:

date_from = None

This is first part of of the smart fil­ter based on the Exif date.

If you are not sure if your images con­tain valid Exif data, have a look at "Check the Exif data of your images to pre­pare your pho­to frame for smart playlists" and run the Exifcheck script.

The for­mat for this val­ue is "yyyy:mm:dd" (e.g. "2016:12:25" - you need to use colon sep­a­ra­tors). All images that have been tak­en from this day on will be shown, lat­er pho­tos, or pho­tos with miss­ing Exif data, will be exclud­ed from the playlist.

"None" means that no fil­ter­ing is applied.

date_to = None

This is the sec­ond part of the smart fil­ter based on the Exif date.

Spec­i­fy here the date until which images are includ­ed in the playlist. Send­ing a val­ue like "2018:6:21" via MQTT will result in the exclu­sion of pho­tos with a new­er Exif date than June 21, 2018.

quit = False

You can ter­mi­nate Pi3D by send­ing a quit com­mand. This is more for test­ing pur­pos­es than for any­thing else.

paused = False 

Some­times you want to stop at an image to show it to some­one or just to enjoy it longer. Just send a "pause" com­mand and Pi3D will sus­pend the play­back.

If you send the same com­mand again, play­back will resume.

Set­ting up the MQTT server/post office

# set up MQTT listening
client = mqtt.Client()
client.username_pw_set("myuserid", "mypassword") # replace with your own id
client.connect("postman.cloudmqtt.com", 16845, 60) # replace with your own server

Around line 195, you will find the set­tings for your MQTT serv­er. Enter your user­name, pass­word, serv­er and port address.

I have said if often before but I'll say it again. If you are using a dig­i­tal pic­ture frame in a res­i­den­tial set­ting, there is no bet­ter image view­er for the Rasp­berry Pi than Pi3D. The super-smooth and unob­tru­sive cross­fades are a plea­sure to observe and will take your pho­to view­ing expe­ri­ence to a new lev­el.

A big Thank You to Pad­dy, the co-author, and main­tain­er behind this soft­ware gem!