Denis Hierholzer

PicR (Picture Randomizer)


As most of you we have several thousand pictures at home on our harddisk from events like weddings, holidays and trips to adventure parks or just the every-day pictures we take with our smartphones. Usually these pictures are just there and nobody really takes the time to have a look at them.

The problem is that if you want to see some pictures it's usually something specific like a specific person. Furthermore I wasn't really satisfied with the randomizing algorithm most of the image viewers have implemented. You often see the same pictures very often while others never appear.

So I started to create my own picture randomizer based on the faces Picasa has found. All self-developed parts are created with PowerShell.

History and Background

When I first started with the Picture Randomizer (PicR) I was using Owncloud on my own Linux server which also already served as a web server with a MySQL database. Based on this setup I've created my first version of the PicR with MySQL and PHP. So it was a pure web solution which was great.

After a while I wasn't satisfied with Owncloud and switched to Dropbox as a file hoster so I got rid of my MySQL database and the web server environment. PHP wasn't easy for me to use because it's not the language I use every day. So it took a lot of time and research to develop PicR in PHP. That's why I've chosen PowerShell for the next release of PicR. It's the language I use regularly at work so it's easy for me to implement new features in a short amount of time and I also strengthen my knowledge for work.

Some words about the concept: Picasa already uses its ini files to save the face data so I also used a similar approach for the picture tags and saved them in ini files (“.tags.ini”). I know that pictures contain EXIF information and that you can also save your tag information there. Unfortunately this means modifying the picture itself and if you add many tags you end up with a lot of changed files. As pictures are not very small and I work with a cloud service provider (Dropbox) which means that all files are uploaded to the internet, every tag change would cause the affected picture to fully upload via my not-so-fast internet connection. By using the ini file concept I avoid this.

Furthermore if you migrate data to another location/provider your files and the structure usually stays the same. That's why I've decided to store as much data as possible in files and not within the database. The database information are mostly created by the Collect-Tags script. Only a small amount of data gets lost of the database needs to get recreated from scratch (tag-person, tag-category assignments and exclude markers on tags). All other information is saved in files.

Components Overview

  • Google Picasa (product retired, but still downloadable)
    Used to find and assign faces to persons, saves the faces tags in a file named “.picasa.ini”
  • Microsoft SQL Server Express
    Free (like in “free beer”) database engine that handles our little database. Download is available here
  • Script Set-FileTag
    Used to manage file tags that can be assigned to files and folder. Saves tags in files named “.tags.ini”
  • Script Collect-Tags
    Used to collect face and file tags as well as some more meta information about pictures and saves them in a SQL database
  • GUI script “PicR”
    Used to display random pictures based on person, category and folder filters

Google Picasa

Picasa is a picture management software developed by Google. Unfortunately it's no longer maintained and thus it's defined as “retired”. But you can still download and use the latest version.

Picasa is able to find faces in pictures and you can assign names to these faces. It can also find similar faces so it can group pictures of the same person. Picasa saves the found faces with the assigned person names in a file called “.picasa.ini” which is located in the same folder as the picture.

Microsoft SQL Server Express

SQL Server Express with its limitations is absolutely enough for our use case. At first I've tried to work with a SQLite DB (database in a single file) but the performance was extremly bad so I switched over to a mutual database engine. SQLite would have been great for transportability because it's easy to move to another computer. With SQL Server Express you always have to install a heavy database engine.

SQL Server Express limitations:

  • max DB size: 10 GB – I think I'll never come even near to this limitation
  • no SQL Server Agent service – backups must be done manually or scheduled outside of SQL Server
  • hardware: single physical CPU, max 1 GB RAM usage per SQL Server instance
  • no advanced features like DB mirroring, encrypted backups or SQL profiler


Set-FileTag is a PowerShell GUI script used to manage tags on files and folders. It's available via the context menu on all files and folders (right-click -> Set-FileTag”).

In the list on the top you can see the selected files and folders. Mark one of them and you can see the assigned tags in the lower left hand-sided list. All available tags are listed in the lower right hand-sided list. If you miss a tag just add it with the button “New Tag”. To assign a selected tag to all listed files and folders in the top list, just click on the button “Assign to all”. You can add more files to the selection by just performing a right-click->SetFileTag on them.

It's compiled as EXE file and is located in C:\Windows\Set-FileTag.exe. It's added to the context menu like described here

Set-FileTag.exe -FilePath \”%1\”

@=“Set-FileTag.exe -FilePath \\\”%1\\\”“




Collect-Tags is a PowerShell script that runs server-side and searches based on a given root folder for all files called “.picasa.ini” and “.tags.ini”. All listed files and folders in the found ini files are written to a SQL database with some more meta information.

Some of the collected information are:

  • Picture path
  • Tags
  • Faces with their location in the picture

Collected information in future releases:

  • Location data where the picture has been taken (GPS)
  • EXIF data (e.g. camera model)


PicR is a GUI tool written in PowerShell. Based on the data in the SQL database it displays a random picture filtered by persons, categories or folders. It also offers a category editor where you can assign tags to categories.


  • filter by person (operator AND/OR, randomizer priority on person/picture)
  • filter by category (operator AND/OR)
  • filter by folder
  • picture preview
  • slideshow with customizable timer
  • picture in extra window
  • picture in fullscreen (supports multiple screens)
  • picture history and previous picture
  • advanced randomizer that knows already shown pictures
  • keyboard controls (e.g. start/stop slideshow, next picture, previous picture)
  • copies picture to local temp folder for faster loading
  • configureable picture size and quality
  • excludeable tags (tagged pictures are not shown by default)
  • show meta data in picture (e.g. face location, person name)
  • show meta data in extra window
  • display picture in included web server (accessible in local network)
  • copy current filter selection to a folder (as file)
  • copy current filter selection to a file (as text list)
  • open current picture in default image viewer
  • open folder of current picture
  • rotate picture left/right and save as original
  • edit tags of current picture (opens Set-FileTag)



PicR - Category Editor - Person Tags

PicR - Category Editor - Person Tags

PicR - Category Editor - File Tags

PicR - Category Editor - File Tags

PicR - Meta Data Window

PicR - Meta Data Window

Database Structure

SQL Server Tables >>