Looks like many people are having problem with the function imagerotate from the gd library on php.
It also looks like the php guys have made a fork of the gd library and included a heavily customised version of it in php. Our problem is, the Ubuntu guys decided to get rid of that imagerotate and some others for security reasons. Fair enough, but how do I make it work now??

Here is how I do it on my server.

apt-get install build-essential

will install what you need in order to compile the original version of the php-gd library.

Get the sources of the version of php that you have on your server from the php.net website.

wget blabla

install some extra libraries needed during the compilation

apt-get install libxml2 libxml2-dev libjpeg libjpeg62 libjpeg62-dev

uncompress the php tar.bz2 archive

tar xjvf php-5.2.4.tar.bz2 
cd php5.2.4

run the configure script and make sure you enable gd as a shared library

./configure --enable-shared=gd --with-jpeg-dir

wait some time…
Once this is done, you should be able to go to the ./module directory and find your gd.so file.
Then type:

locate gd.so

If you don’t get any answer try refreshing your locate database with updatedb
Once you know where gd.so is supposed to be, make a backup of gd.so, copy the one you just created in that place.
Then you can restart your apache server.

In order to check if the new functions are working you can type this:

php -r "var_dump(function_exists('imagerotate'));"
php -r "var_dump(function_exists('imagecreatefromjpeg'));"

You can try with several other functions.

Leave a Reply

Your email address will not be published. Required fields are marked *