Home > Backend Development > PHP Problem > What should I do if php does not support jpeg?

What should I do if php does not support jpeg?

藏色散人
Release: 2023-03-06 06:54:02
Original
3034 people have browsed it

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.

What should I do if php does not support jpeg?

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()
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template