Making a Twitter Collage
This is a lazy way of making a collage of Tweets.
I was originally going to use this method:
but, sadly, gnome-web-photo
crashed repeatedly when I tried to use it. It is a typically unloved Linux program, hundreds of bug reports, but no one looking to fix them.
Instead, I used the Scheenshotlayer API - I passed wget
the URLs and got back a bunch of full sized screenshots.
wget
doesn't name the files nicely - so you just get the full URl as the filename. Here's a quick bash script to rename them all with padded zeroes.
BASH
var=1;
for file in *;
do
printf -v num '%02d' $var ;
mv ${file} ${num}.png;
var=$((var+1));
done
OK, so, how do we grab just the parts that we want? Rather than using any fancy image recognition stuff, I measured the area by hand.
And, to cut the image out? ImageMagick to the rescue! Let's grab a rectangle 624 pixels wide, but 900 tall, starting at 400 pixels from the left and 0 pixels from the top.
convert tweet.png -crop 624x900+400+0 +repage cropped.png
The +repage
is needed to prevent offsetting issues.
And, to do that for all images in a directory:
mogrify -crop 624x900+400+0 +repage *.png
Right! Let's lay these out. Without a doubt, the simplest way is using ImageMagick's montage
command.
montage *.png -tile 4x10 -geometry +0+0 montage.png
This lays out all the images on a grid 4 images wide and 10 high. The -geometry
ensures there is no border around the image.
I then resized the image suitable for sticking on a web page.
The result?

TODO
The only rough spot in this process is cropping the images. At the moment, there's a lot of empty space around the Tweets. Some - with smaller photos - have gaps at the top and bottom. A more intelligent method of extracting the information is needed!
mike says: