Russian GD 2.0.33 Guide | Go Back

I wrote this guide for those people, who would like to print cyrillic letters in GD. Since native GD fonts do not support Cyrillic characters, the only way to print out Cyrillic on GD is to use TrueType fonts. If you are using GD very often, using ttf is not the best and speedy solution. TrueType fonts do require more memory, time and CPU usage for producing an image in GD, whereas native GD fonts take up a lot less memory and time, because they are already compiled into GD.

Russian GD 2.0.33 Guide
or
Support for Cyrillic letters in GD 2.0.33

1) Who should use this guide?
Those of you who are really worried about productivity and speed in producing images with Cyrillic letters using Boutell’s GD.

2) On what operating systems has this guide been tested on?
This guide should work on all flavors of Linux, FreeBSD and OpenBSD systems. If you make it work on any other platform, please let me know :-)

3) Stuff we’ll be needing (sources)
Before version 2.0.33 all GD releases did not have GIF image support. This happened because of LZW patent issues. The patent has been expired and gif support will be added to all GD releases from now on.

Create a “GD” folder in /usr/local/src and download the following sources to the directory /usr/local/src/GD:
- GD v2.0.33 sources from Boutell.com
- Perl GD Module v2.28 sources from Lincoln Stein

Other Files:
- JPEG v6b sources from Independent JPEG Group
- TIFF v3.6.1 sources from Libtiff.org
- LibPNG v1.2.8 from Libpng.org
- zlib v1.2.3 from Zlib.net
- Freetype v2.1.10 from The FreeType Project
- Russian GD Patch from this site

3.1) Checking for existing versions of GD, JPEG, TIFF, PNG, FreeType and ZLib
Before trying to install the following libraries it’s a good idea to check if you have existing versions already running on your machine. If you have one of the recent Linux distributions, you most likely already have the libraries installed. If you already have JPEG, TIFF, PNG, FreeType and ZLib installed, there is no need to reinstall them, unless you are running very very old versions.

Here is how to check if you have GD, JPEG, TIFF, PNG, FreeType and ZLib installed on RedHat Linux:

# rpm -q -a | grep gd
# rpm -q -a | grep libjpeg
# rpm -q -a | grep libtiff
# rpm -q -a | grep libpng
# rpm -q -a | grep freetype
# rpm -q -a | grep zlib

And here is the output on my RedHat Linux 9.0 install:

gd-1.8.4-11
gd-devel-1.8.4-11
libjpeg-6b-26
libjpeg-devel-6b-26
libtiff-3.5.7-11
libtiff-devel-3.5.7-11
libpng10-devel-1.0.13-11
libpng-1.2.2-20
libpng10-1.0.13-11
libpng-devel-1.2.2-20
freetype-devel-2.1.3-6
freetype-2.1.3-6
freetype-utils-2.1.3-6
zlib-1.1.4-8
zlib-devel-1.1.4-8

If you have a similar output, you will not have to install any image libraries. However, you have to make sure that you have the “-devel” RPMs installed. These are the source libraries that WILL BE REQUIRED by GD that we will be reinstalling! If you do not have the -devel packages, you might find it easier to get the RPM file instead of removing the RPM and installing from source. In this case, rpmfind.net is your friend :)

4) Installing LibPNG and Zlib
Skip this step if libpng, libpng-devel, zlib and zlib-devel are already installed. We first start with LibPNG and Zlib, because the installation is a little tricky.

# cd /usr/local/src/GD
# tar zxf libpng-1.2.8.tar.gz
# mv libpng-1.2.8 libpng
# tar zxf zlib-1.2.3.tar.gz
# mv zlib-1.2.3 zlib
# cd zlib
# ./configure –shared –prefix=/usr
# make
# make test
# make install
# cd ../libpng
# cp scripts/makefile.linux makefile

Before running make and make install for LibPNG, edit the makefile and change the line prefix=/usr/local to prefix=/usr

The reason why we changed the prefix (path) is because I personally prefer main libraries to be in /usr instead of /usr/local. You may change the default installation path to /usr/local if you want to.

Now execute the following commands:

# make
# make test
# make install

LibPNG is now installed.

5) Installing TIFF and JPEG
Skip this step if libtiff, libtiff-devel, libjpeg and libjpeg-devel are already installed.

# cd /usr/local/src/GD
# tar zxf tiff-v3.6.1.tar.gz
# tar zxf jpegsrc.v6b.tar.gz
# cd tiff-v3.6.1
# ./configure –prefix=/usr
# make
# make install
# cd ../jpeg-6b
# ./configure –prefix=/usr –enable-shared –enable-static
# make
# make test
# make install

This should take care of the installation.

6) Installing FreeType
Installing FreeType is very easy as well. Just execute the following commands:

# cd /usr/local/src/GD
# tar zxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure –prefix=/usr –enable-shared –enable-static
# make
# make install

8) Configuring, patching and installing GD
Now we are going through the most important part - installation of GD. Before we start the source installation I recommend to remove any existing version of GD installed in the system. You do not want multiple versions of GD sitting in the system, especially mix of old and new versions of GD. If you have a package system such as RPM, run the following commands:

# rpm -e gd
# rpm -e gd-devel

If you are using a BSD-type system or other non-RPM linux disribution, you have to remove existing versions of GD manually. Type “locate gd.h” and see where GD header files are. Remove the following files: gd.h, gd_io.h, gdcache.h, gdfont*.h from the system. If you have installed GD from sources previously, go to the GD source folder and try typing “make uninstall”.

Now we are ready to install.

# cd /usr/local/src/GD
# tar zxf gd-2.0.33.tar.gz
# mv russian_2.0.33.patch gd-2.0.33
# cd gd-2.0.33
# patch < russian_2.0.33.patch
patching file gdfontg.c
patching file gdfontg.h
patching file gdfontl.c
patching file gdfontl.h
patching file gdfontmb.c
patching file gdfontmb.h
patching file gdfonts.c
patching file gdfonts.h
patching file gdfontt.c
patching file gdfontt.h

Then, we run configure, make and make install (if you don’t have X-Windows installed, remove the –with-x switch).

# ./configure –prefix=/usr –enable-jpeg –enable-freetype –enable-xpm
–x-includes=/usr/include/freetype –with-x
# make
# make install

If you get any errors during the configure call, check out the output and see where it stops. In most cases configure should run without a problem. In case you get an error with make, look at the last couple of lines, you should be able to find out what’s wrong.

9) Installing Perl GD Module
Now we have GD installed and fully operational. What’s next? Let’s install GD.pm - a perl module written by Lincoln Stein.

# cd /usr/local/src/GD
# tar zxf GD-2.28.tar.gz
# cd GD-2.28
# perl Makefile.PL
# make
# make test
# make install

After you type perl Makefile.PL, the configure script will ask you a couple of questions. Answer “Y” to all of them and everything should go smoothly. Execution of “make test” might give you some errors. Don’t worry - simply ignore them.

Here is a sample output of our compiled GD:



Pretty cool heh?

That’s it! You’re done! Congratulations :-)

Posted by MegaZ on 11/08/2003.

4 Responses to “Russian GD 2.0.33 Guide”


  1. Fill says:

    Recompile php ;)

  2. Tee says:

    Hey, i did this tutorial, but the gd is not workin within php-pages. Any help?

  3. Anonymous says:

    Hello, I just wanted to say you have a very informative site which really made me think, Thanks ! A site with a wealth of info.!…thanks very much! Have a nice Day!!

  4. Anonymous says:

    Howdy! Great site. Great content. Great! I can recommend this site to others!


Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Powered by WP Hashcash