Oct 09

Solved – Call to undefined function imagecreatefromjpeg

Even if you are installed php with gd, error message ” undefined function imagecreatefromjpeg () ” may appear on php. specifically when installing fresh opencart web application you may definitely face this issue as I did. In Opencart installation process, installer itself checks whether gd is installed, but unfortunately not identify the other important packages such as libJPEG and libPNG are installed or not. Here is how I fixed the that error on Centos.


Fatal error: Call to undefined function imagecreatefromjpeg() in /../library/image.php on line 34

(01) Install libjpeg and freetype

Centos :-
yum install libjpeg-devel
yum install freetype-devel

For Ubuntu :-
apt-get install libjpeg-dev
apt-get install libfreetype6-dev

(02) Configure and compile php

make clean
make distclean

***you must clean the php before configuring*
When compile gd extension, use the flag –with-jpeg-dir and –with-freetype-dir

no need to define directory(DIR) location of each flag if you are installed libjpeg and freetype using yum commands, otherwise it may be need to set DIR
location of each.

example php configuration
./configure –with-gd –with-jpeg-dir –with-freetype-dir

(03) Restart Apache

below is the sample output of php info file after successful installation.

php gd support verification

php gd support verification















Cheers 😀

Leave Your Thought Here