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!