How to Enable Image Support for PHP

If you're trying to enable thumbnail generation on MediaWiki and you encounter an error like Fatal error: Call to undefined function: imagecreatefromjpeg() ., Download and install the JPEG library from here., This will install the library in your...

12 Steps 2 min read Medium

Step-by-Step Guide

  1. Step 1: If you're trying to enable thumbnail generation on MediaWiki and you encounter an error like Fatal error: Call to undefined function: imagecreatefromjpeg() .

    For SLES 9 simply install the following rpms: t1lib-1.3.1-569.1.i586.rpm php4-gd-4.3.4-43.8.i586.rpm
  2. Step 2: Download and install the JPEG library from here.

    The file you want to download is jpegsrc.v6b.tar.gz.

    Unzip, extract, configure, make and install by executing these steps: tar xvfz jpegsrc.v6b.tar.gz cd jpeg-6b ./configure make make install , Unfortunately if you plan on compiling GD (GD is the graphics library that PHP uses) from scratch you will also have to copy over the header files manually by doing this: cp ./include/j*.h /usr/local/include ,, Even though you might not configure PHP using PNG support, you can't for some reason configure GD without it.

    Go here, scroll down to where you see "Source Code" and download a version, this example will use the .tar.gz version. tar xvfz libpng-1.2.8-config.tar.gz cd libpng-1.2.8-config ./configure make make install , If you already have PHP installed on your machine you may have to download the source all over again and recompile it.

    Go to PHP's home page and download the most recent version of the
    4.x source code.

    Extract it and configure.

    The following configure options enable MySQL and Apache libraries as well as the image libraries, if you have any other libraries that you wish to use, make sure to include them. ./configure
    --with-mysql
    --with-apxs2=/usr/sbin/apxs \
    --with-gd
    --with-jpeg
    --with-jpeg-dir=/usr/local \
    --with-png
    --with-png-dir=/usr/local
    --with-zlib-dir=/usr (the backslashes denote a new line) make make install ,,,
  3. Step 3: This will install the library in your /usr/local directory.

  4. Step 4: Only do this if you want to compile GD yourself.

  5. Step 5: Download and install the LIBPNG library.

  6. Step 6: Now that these 2 libraries are installed

  7. Step 7: it's time to compile PHP.

  8. Step 8: After this

  9. Step 9: it's time to restart Apache: httpd -k restart

  10. Step 10: If you get a warning about the PHP module already being loaded

  11. Step 11: remove either the LoadModule in httpd.conf or remove the php.conf file in /etc/httpd/conf.d.

  12. Step 12: Now you should have images support for PHP!

Detailed Guide

For SLES 9 simply install the following rpms: t1lib-1.3.1-569.1.i586.rpm php4-gd-4.3.4-43.8.i586.rpm

The file you want to download is jpegsrc.v6b.tar.gz.

Unzip, extract, configure, make and install by executing these steps: tar xvfz jpegsrc.v6b.tar.gz cd jpeg-6b ./configure make make install , Unfortunately if you plan on compiling GD (GD is the graphics library that PHP uses) from scratch you will also have to copy over the header files manually by doing this: cp ./include/j*.h /usr/local/include ,, Even though you might not configure PHP using PNG support, you can't for some reason configure GD without it.

Go here, scroll down to where you see "Source Code" and download a version, this example will use the .tar.gz version. tar xvfz libpng-1.2.8-config.tar.gz cd libpng-1.2.8-config ./configure make make install , If you already have PHP installed on your machine you may have to download the source all over again and recompile it.

Go to PHP's home page and download the most recent version of the
4.x source code.

Extract it and configure.

The following configure options enable MySQL and Apache libraries as well as the image libraries, if you have any other libraries that you wish to use, make sure to include them. ./configure
--with-mysql
--with-apxs2=/usr/sbin/apxs \
--with-gd
--with-jpeg
--with-jpeg-dir=/usr/local \
--with-png
--with-png-dir=/usr/local
--with-zlib-dir=/usr (the backslashes denote a new line) make make install ,,,

About the Author

G

Gerald Anderson

A seasoned expert in technology and innovation, Gerald Anderson combines 16 years of experience with a passion for teaching. Gerald's guides are known for their clarity and practical value.

80 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: