Home >Backend Development >PHP Problem >What should I do if php does not support jpeg?
Solution to the problem that php does not support jpeg: first download "jpegsrc.v8b.tar.gz" from the official website; then compile the jpeg module and compile the gd module; finally, change "gd. Just add the so" module.
Recommended: "PHP Video Tutorial"
The GD library of php in liunx does not support jpeg by default
Use compiled and installed php, but when uploading jpg files, an error is reported:
Call to undefined function imagecreatefromjpeg()
It turns out that the gd library does not support jpg by default. You can add jpg support to the gd library. When compiling and installing php, do not include the gd library first. After the installation is complete, compile the gd library separately.
Compile the jpeg module. This needs to be downloaded from the official website.
[root@linux-node1 ~]# wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz [root@linux-node1 ~]# tar -xf jpegsrc.v8b.tar.gz [root@linux-node1 ~]# cd jpeg-8b [root@linux-node1 jpeg-8b]# ./configure –prefix=/usr/local/jpeg –enable-shared –enable-static [root@linux-node1 jpeg-8b]# make && make install
Compile the gd module. This is in the php source code package.
[root@linux-node1 gd]# pwd /usr/local/src/php-5.6.30/ext/gd [root@linux-node1 gd]# /usr/local/php/bin/phpize [root@linux-node1 gd]# ./configure –with-php-config=/usr/local/php/bin/php-config\ –with-jpeg-dir=/usr/local/jpeg\ –with-freetype-dir [root@linux-node1 gd]# make && make install
Finally, add gd in php.ini Just add the .so module
Note:
If the above cannot solve the problem, please install the following package
[root@linux-node1 ~]# yum install libjpeg-devel freetype-devel libpng-devel
The above is the detailed content of What should I do if php does not support jpeg?. For more information, please follow other related articles on the PHP Chinese website!