Php Fatal error: Call to undefined function imagecreatefromjpeg ()

Source: Internet
Author: User
Tags php source code phpinfo

Code

The code is as follows: Copy code

If (! Imagecreatefromjpeg ("./testimg.jpg "))
{
Echo "imagecreatefrom((testimg.jpg) failed! N )";
}
Else
{
Echo "imagecreatefrom((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 describes how to install jpeg in gd.

The code is as follows: Copy code

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.

Use php + apache in windows.

First, open php. ini and find"Extension = php_gd.dll ",Remove the 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!

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.