php imagerotate function on ubuntu hardy

Reading Time: < 1 minuteLooks 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.

			
Reading Time: < 1 minute

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
compile
make

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.

By Marc Olivier Meunier

Marc has spent the past few years putting oil on the fire of a hyper growth ad tech company. At Smartly.io he was in charge of scaling the support and its culture. At Eficode he is now leading an engineering team and running operations. He leads by example and puts a lot of emphasis on diversity and inclusion, constantly working to create a safe environment. A warm leader with a passion for memorable experiences and innovation.
Find Marc on Linkedin

Leave a Reply

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