PhpFatalerror: Calltoundefinedfunctionimagecreatefromjpeg ()

Source: Internet
Author: User
Imagecreatefromjpeg is an image processing function, but Fatalerror: Calltoundefinedfunctionimagecreatefromjpeg is found in use... the imagecreatefromjpeg function is an image processing function. However, the Fatal error: Call to undefined function imagecreatefromjpeg () error is found during use. the following section describes some tutorials. let's take a look.

The code is as follows:

if(!imagecreatefromjpeg("./testimg.jpg")) {     echo "imagecreatefromjpeg(testimg.jpg) failed!n)"; }   else  {     echo "imagecreatefromjpeg(testimg.jpg) succn)"; }

If you use this function to prompt php Fatal error: Call to undefined function imagecreatefromjpeg ()

This error occurs because gd jpeg is not installed. although you use phpinfo to view gd, gd does not support jpeg. before installation, my phpinfo is as follows:

gd GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.2.1 GIF Read Support enabled GIF Create Support enabled PNG Support enabled libPNG Version 1.2.10 WBMP Support enabled XBM Support enabled

Obviously, gd does not support jpeg. the following code installs jpeg in gd:

1. find the php source code directory.

2. go to the ext/gd directory.

3./usr/local/php/bin/phpize

4.../configure-with-php-config =/usr/local/php/bin/php-config-with-jpeg-dir-with-freetype-dir

5. make & make install

6. restart httpd

View phpinfo after installation

gd GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.2.1   GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version 6b PNG Support enabled libPNG Version 1.2.10 WBMP Support enabled XBM Support enabled

Obviously, JPEG Support enabled is added.

Using php + apache in windows:

First, open php. ini, find "extension = php_gd.dll", remove the previous ";" comment, and restart apache.

If such problems still occur, first check php. which Directory is the extension_dir value of ini? check for php_gd.dll in that directory. if not, download php_curl.dll and copy libeay32.dll and ssleay32.dll in the php directory to c: windowssystem32 to restart apache, OK!


Link to this article:

Add to favorites ^ please keep the tutorial address.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.