· 482 words · 3 minute read

Spotify Scannables

For my ‘sister project’ I had the idea to print physical albums for virtual Spotify albums. It works using the ’new’ Spotify barcodes. Read the original blog-item.

My first attempt to create these was a very manual approach: I made a screenshot from Spotify on my phone (the only place where the barcode is shown), cropped the code, pasted this in a Pages-file (the Apple-equivalent of Word) and added an album cover + tracklisting I found on Wikipedia. This would take over half an hour per album!

Automatically creating album-covers with a Spotify code #

In my 2nd attempt I tried to script as much of this process as I could. In addition, I decided to skip the tracklisting (keeping just the cover + Spotify code).

This means I no longer needed to print double-sided. Which in turn meant I can have the covers be printed as ‘square photos’, so they look great now!

Bash-scripting #

I had to dust-off my scripting capacities and my first attempt went a bit ‘overboard’. I created a script that:

  • automatically cuts the Spotify-code, the album-title and artist-name from an Android screenshot, using GraphicsMagick
  • uses Tesseract (an OCR-engine) to parse the album-title and artist into text
  • asks the user if the OCR was done correctly (with the option to provide a better album/artist)
  • uses Glyr (a metadata search-engine for music) to get a load of album-covers
  • finds the best-looking album-cover (approximately, using filesize) using the artist/album from the previous step
  • pastes the Spotify-code on top of the album-cover (in two versions: with the code either in the left or right bottom-corner)

Which worked GREAT! Except that all albums returned by Glyr were kind of ‘meh’-quality. I introduced several improvements, but in the end it never was ‘great’.

You can download v1 here to play around with.

Version 2 of the Bash-script #

I took my losses and re-examined my options. I found that the resolution of the cover in the Android-screenshot was actually a lot better than whatever Glyr returned. So I greatly simplified my Bash-script. Now it only:

  • automatically cuts the Spotify-code and the cover from an Android screenshot, using GraphicsMagick
  • pastes the Spotify-code on top of the album-cover

Optionally, you can enable Tesseract to have a cool filename as well.

Ofcourse v2 is also available to play around with.

The end-result #

Here’s some example albums. You can scan them with Spotify (on mobile: tap ‘search’ and then the ‘camera’ in the search bar).

Adele - 25
Anouk - Fake It Till We Die
Fleshgod Apocalypse - King

Printed #

I had them printed as ‘square photos’, they look great!

All covers

Generating JPG #

If you plan to do this as well, you need to convert the PNGs to JPG before you can print them, which is easy with GraphicsMagick:

for f in result/*.png; do gm convert $f -unsharp 2x0.5+0.7+0 $f.jpg; done

This adds some sharpening as well, which looks a bit nicer when printing IMHO

album-covers obviously don’t fall under the Creative Commons license