Click here to see all examples.
This is the product of a MAAD 26210 assignement where we were instructed to create art from data about ourselves. I used my Last.fm data to pull the album covers from every song I have listened to over the past few years and then arranged them based on saturation, hue, and brightness.
-
Make sure you have python installed. Download dependencies by running this command in a terminal window:
pip3 install pillow requests python-dotenv
-
Download your last.fm data from benjaminbenben.com/lastfm-to-csv. This will generate a CSV file with the following columns:
Artist, Album, Song, Time Scrobbled
-
Get Spotify API Keys (see below).
-
Run the following command to download album covers:
python3 album_cover_fetch.py YOUR_CSV.CSV NUM_THREADS
Replace
YOUR_CSV.CSV
with the path to your downloaded CSV file, andNUM_THREADS
with the number of worker threads you'd like to use (6 is the default if unspecified). This will download all the album covers into a folder namedalbum_covers
. -
Once all your images are downloaded, it's a good idea to back them up, as the next script is destructive. Occasionally, there might be duplicate albums covers. This mainly occurs when there exists both a regular and deluxe version of album.
-
Run the following command to create the collage:
python3 image_maker.py
Here are the possible arguements that can be passed:
python3 image_maker.py COMPRESSED_DIMENSIONS SORT_CRITERIA --reverse
If unspecified,
COMPRESSED_DIMENSIONS
will be 64 meaning each album cover will be cropped to 64 x 64.If unspecified,
SORT_CRITERIA
will be "brightness". The other options are "hue" and "saturation".If
--reverse
is specified, the images will be sorted in descending order.By default, the images are arranged in a circular formation. If you want to arrange them from side to side or to double sort them (e.g., sort top to bottom by brightness and then left to right by hue), you will have to poke around in the code. The relevant lines all begin with:
# Change Me:
-
Your final output will be saved as
collage.jpg
.
To use album_cover_fetch.py
, you'll need to have your own Spotify API keys (client ID and secret key). Follow these steps to obtain your keys and set up the environment variables:
-
Go to the Spotify Developer Dashboard and log in or create an account if you don't have one.
-
Click on "Create an App" and fill in the required information to create a new Spotify API application.
-
After creating the app, you'll find the "Client ID" and "Client Secret" on the application's dashboard.
-
Create a
.env
file in the project directory and add your client ID and secret key:CLIENT_ID=your_client_id_here CLIENT_SECRET=your_client_secret_here
The script will automatically load the client ID and secret key from the
.env
file.
The biggest thing that needs to be fixed is the presence of duplicate duplicate albums covers. This most often occurs when there are deluxe and regular albums or when a single has the same cover as an album.