Created
November 22, 2011 00:07
-
-
Save madsen/1384422 to your computer and use it in GitHub Desktop.
Join the tiles from http://xkcd.com/980/huge/ into a single image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl | |
#--------------------------------------------------------------------- | |
# Join the tiles from http://xkcd.com/980/huge/ into a single image | |
# Copyright 2011 Christopher J. Madsen | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the same terms as Perl itself. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the | |
# GNU General Public License or the Artistic License for more details. | |
#--------------------------------------------------------------------- | |
# First: | |
# wget http://imgs.xkcd.com/money_tiles5/tile_000_0{00..48}_0{00..32}.png | |
use strict; | |
use warnings; | |
use Image::Magick; | |
my $tileWidth = 256; | |
my $tileHeight = 256; | |
my $img = Image::Magick->new(size => "12528x8352"); | |
$img->ReadImage('xc:white'); | |
$img->Set(units => 'PixelsPerInch'); | |
$img->Set(density => '180x180'); # estimate | |
for my $r ('00' .. '32') { | |
print "Processing row $r...\n"; | |
for my $c ('00' .. '48') { | |
my $i = Image::Magick->new; | |
$i->Read(filename => "tile_000_0${c}_0$r.png"); | |
$img->Composite(image => $i, x => $c * $tileWidth, y => $r * $tileHeight, | |
compose => 'over'); | |
} # end for each $c | |
} # end for each $r | |
print "Saving image...\n"; | |
$img->Write('xkcd_980_huge.png'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, padded number expansion isn't available in Bash 3.2.
$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
$ echo {0001..5}
1 2 3 4 5