LastCollage is a bash script that generates a collage of album covers from your last.fm profile. It runs on linux and Mac and on Windows with cygwin.
Here is the kind of picture it produces:
It makes a really nice desktop wallpaper. Check out the gallery to see many other examples.
Inspiration: Gijsco's Last.fm Desktop Generator for the use of last.fm data, and Jamie Zawinski's webcollage, for the collage.
NEW: please check wallpaperfm.py, a new script which includes the collage and two more wallpapers (and is much faster) (and has less requirements).
You need these 2 files (lastCollage and parse_pictures.xsl).
lastCollage [Show source]
parse_pictures.xsl [Show source]
If you're on a Mac and have macports installed, run this before installing the script, to install wget and ImageMagick:
- You need 2 files to use it: the script itself (lastCollage) and parse_pictures.xsl.
- The script uses ImageMagick, xsltproc and bc. This is fairly standard stuff. Install them if you don't have them.
- I've also noticed that wget is not installed by default on Mac.
sudo port install wget
sudo port install imagemagick
If you're on Windows with cygwin, you'll probably need to install wget, xsltproc and bc, since they don't seem to be there by default.
Simply run setup.exe and select them for installation.
You'll find wget in the 'Web' category, xlstproc in the 'Interpreters' category (as 'libxslt') and bc in the 'Utils' category (as 'bc the GNU numeric processing language and reverse Polish calculator').
Here is one way to install lastCollage from the command line:
chmod a+x lastCollage
lastCollage is then run with ./lastCollage and will produce a jpg file.
For a limited period: the web version, no install necessary.
will run the script with the default values:
I'll be using the following parameters:-
(u) Username: Koant
(t) How far back: overall (should be one of '3month', '6month','12month' and 'overall')
(n) Name of the picture: Koant.jpg
(c) Size of the canvas: 1280x1024
(f) Size of the final image: 1280x1024
(a) Album size: 300 pixels
(o) Album opacity: 80 (in [0 100]. 100 means no transparency)
(g) Gradient size: 20 pixels (should be between 1 and half the album size)
(O) Darkness of final image: 70 (in [0 100]. 0 makes the image completely black)
(i) Number of iterations: 1
You can change the default values by passing the following parameters:
-t one of '3month', '6month', '12month', 'overall'
-n name of the picture
-c size of the canvas as WidthxHeight
-f size of the final image as WidthxHeight
-a album size in pixels
-o album opacity, in [0 100]. 100 means no transparency.
-g gradient size in pixels
-O darkness of final image, in [0 100]. 0 makes the image completely black.
-i number of iterations, 1 by default.
For example, if you want to have quick try with a smaller final image, for example 640x480, and for the user RJ, use the following command. We use a smaller album size as well, say 150 pixels.
./lastCollage -u RJ -f 640x480 -a 150
You need an internet connection, for the program to fetch your profile.
When it's finished, a jpg image (username.jpg by default) will contain the collage.
You should be able to use the script in a cron job.
/usr/bin/gconftool -t str -s /desktop/gnome/background/picture_filename "yourpicture" will update the wallpaper in Gnome. (well, almost)
By default, the script uses a uniformly black background, unless the picture $imagename.jpg exists.
In the latter case, this is used as a background.
So if you think your collage looks a bit 'empty' the first time around (there're only 50 albums in the feed, and they don't cover the whole screen due to the overlap), run the script again; it'll look 'fuller' and nicer.
You can also use the '-i' switch to specify how many runs through the album list you want.
Note that '-i 2' is not equivalent to running lastCollage twice in a row, since the first batch is not darkened before applying the second one.
The canvas is the surface which the album covers are pasted on. By default, it has the same dimensions as the final image.
If you want to have a black border around the collage, use a canvas that is smaller than the final image.
If on the other hand, you'd rather not have any borders, use a canvas bigger than the final image.
It has the effect of generating the collage on a bigger surface and cropping the central part to produce the final image.
A good dimension for the canvas in this case is final image size + album size; at a minimum, half of a cover is pasted on the final image.
|Canvas is smaller than final image
||Canvas is bigger than final image
||Canvas is smaller than final image on the y-axis,
and bigger than final image on the x-axis
You can contact me at http://www.last.fm/user/Koant or in the last.fm's forum thread.
Comments, questions and suggestions welcome!
Thu 15 May
Tue 29 Apr
- I've just realized that last.fm also provide the overall top albums - actually that's their default. It's now the default in the script as well.
Mon 31 Mar
- Checks if bc, ImageMagick and xsltproc are installed. Stops and complains if anything is missing. Thanks to holloway87 for the suggestion.
Sun 30 Mar
- Some cosmetic changes - iterations are now shown when adding images.
Thu 27 March 2008
- The shuffled list of albums is now copied multiple times when the switch '-i' is used, instead of reshuffling i times.
This means that it is now less likely to see the same album twice in the final image.
The proof of that is left as an exercise to the reader.
Mon 24 March 2008
- Replaced 'seq' by a for loop, for better compatibility with Mac, following Peddro's remark.
Sun 23 March 2008
- Added the switch '-i' for controlling the number of iterations.
Thur 20 March 2008
- Parameters are now passed through the command line, so there is no need to edit the script anymore.
It should make life easier for Windows users since there seemed to be problems with extra '\r' and other oddities.
Wed 19 March 2008
- Album covers are now resized to a square.
- Added a couple of functions (get_rand and add_sign)
- Added canvas after juxi's suggestion.