Installing tree2image

Dependencies

Before you can use tree2image, you will need Python (version 2.0 or higher) and the Python Image Library (PIL).

Python

To check whether you have an appropriate version of Python, run Python -V:

$ python -V
Python 2.1.1

If you need to install a new version of Python, see the Python download page.

Python Imaging Library

To check if you have the Python Image Library installed, run Python and try importing "Image," "ImageFont", and "ImageDraw":

$ python
Python 2.4.4 (#2, Jan 13 2007, 17:50:26)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image, ImageFont, ImageDraw
>>>

If you need to install the Python Image Library, see the Python Image Library download page

Python Imaging Library Fonts

Finally, you will need at least one PIL font (the default font used by tree2image is helvR08.pil). Note that the Python Image Library package does not include any fonts. The two easiest ways to get fonts are:

  • Download them
  • Construct them from X BDF and PCF fonts, using pilfont.py (which is included with the Python Imaging Library).

Each font consists of a .pil file and a .pbm file. To install a set of font files:

  • Create a new pilfonts subdirectory in your Python site-packages directory (which is typically /usr/lib/python2.4/site-packages).
  • Copy the .pil and .pbm files for each font to the new pilfonts directory.
  • Create a file in your site-packages directory named pilfonts.pth, containing "pilfonts"
[root /root]# mkdir /usr/lib/python2.1/site-packages/pilfonts
[root pilfonts]# cd /usr/lib/python2.1/site-packages/pilfonts
[root pilfonts]# wget http://effbot.org/pil/pilfonts.zip
[root pilfonts]# unzip pilfonts.zip
unzip ../pilfonts.zip
Archive:  ../pilfonts.zip
  inflating: courB08.pil
  inflating: courB10.pil
  inflating: courB12.pil
         . . .
[root pilfonts]# rm pilfonts.zip
[root pilfonts]# echo "pilfonts" > ../pilfonts.pth

Installing tree2image

Once you have Python and PIL installed, installing tree2image is simple.

Unix

  • Download the tree2image script.
  • Modify the first line of tree2image to point to your Python executable (if it's not /usr/bin/python).
  • Place tree2image in a directory in your path (e.g., /usr/local/bin).

Windows