A while ago Think Geek released a poster featuring the Linux mascot Tux, composed of the Linux source code coloured to make up the picture. The description on the page said it was all done in Perl, producing a whopping great PostScript file and I thought to myself "Hmmm, I can do that". So here it is, the shameless rip off it is, a script that takes an image of your choice and some text of your choice and makes a whopping great PostScript file out of them.
Download and install
UNIX (or similar) users should download shanty-3.tar.gz, uncompress then run make install to install Shanty to /usr/local/bin/. Jorge Salamero Sanz has created a Debian package and has kindly ’manified’ the help file, which I’ll include in future releases.
Windows users should download shanty-3.zip, unzip the contents and copy the files to "somewhere sensible". If you have trouble reading the text files in Notepad try Wordpad.
All users will need Perl and the GD library installed. Previous users may wish to read the changelog.
How to use
The most common form is:
shanty -i image_file -t text_file -o output_file
The full form is:
shanty -i image_file [-t text_file] [-o output_file] [-s paper_size] [-d density] [-m margin] [-b background_colour [-x padding] [-n title] [-l orientation] [-rtl] [-btt] [-f font_name] [-altgd]
Windows users should use perl shanty.pl instead of just shanty.
The following table describes each of the Shanty command line switches. Note that in most cases there are multiple ways of specifying the same thing, e.g. -i and -image are synonymous.
Values which contain spaces should be surrounded by double quotes.
|Name of the image to load in. JPG and PNG images are supported. This is the only compulsory field.|
|Name of the text file to load in, if omitted STDIN is used. STDIN is usually the keyboard.|
|Name of the PostScript file to produce, if omitted STDOUT is used. STDOUT is usually the screen.|
|Size of the paper to work with. This field should be one of: a0, a1, a2, a3, a4, a5, a6, letter, broadsheet, ledger, tabloid, legal, executive and 36x36. Default is "a4".|
|Density of the text. Higher numbers are more dense, default is 1.4.|
|The margins of the page in cm. Default is 1.|
|The colour of a backing rectangle to place behind the text. Colours are specified as "R,G,B" with each value between 0 and 255. "off" means no backing colour. Default is "off".|
|The distance in cm that the backing rectangle should extend from each edge of the text. Default is 0.5cm.|
|The title of the output to write as meta-data in the PostScript file. Default is "Shanty output".|
|The orientation of the paper, can be "portrait", "landscape" or "auto". Default is "auto".|
|-rtl||Switch to right-to-left text.|
|-btt||Switch to bottom-to-top text.|
|Specify font. The font name specified must be visible to the PostScript viewer/distiller. Specifying a font name here does not just make a font magically appear. Default is "Courier-Bold".|
|-altgd||If you have problems loading the GD library, try this switch.|
The following command will use face.jpg as the image to base the output on and message.txt as the text to use. The results will be saved in poster.ps. The paper size will be A4 and the orientation of the page will be decided by Shanty. There will be no backing rectangle.
shanty -i face.jpg -t message.txt -o poster.ps
This command is the same as the one above except the orientation now will always be landscape, the page margin has been changed from the default to be 5cm, there is a pale green backing rectangle (with a 1cm gap from it to the text) and the PostScript title has been set to "Hello everyone".
shanty -i face.jpg -t message.txt -o poster.ps -l landscape -m 5 -b 200,255,200 -x 1 -n "Hello everyone"
Lastly, distilling the output to a PDF is highly recommended, it can reduced the file size down as low as 5% of the PS file (blame my shoddy PS output).
In the true spirit of the original idea, I’ve generated a couple of posters made from the OpenBSD 2.8 logo and (a small fraction of) the source from source from OpenBSD 3.4. Two sizes are available: A4 (74KB) and A2 (270KB). You can also view a close-up (28KB) of one eye.