首頁 php教程 php手册 php提示Fatal error: Call to undefined function imagecreate()

php提示Fatal error: Call to undefined function imagecreate()

May 27, 2016 am 08:47 AM
fatal undefined

在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会提示Call to undefined function imagecreate()错误.

例,我在测试一个简单生成图形时实例,新建一个新的 GD 图像流并输出图像,代码如下:

<?php 
header("Content-type: image/png"); 
$im = @imagecreate(100, 50) 
	or die("Cannot Initialize new GD image stream"); 
$background_color = imagecolorallocate($im, 255, 255, 255); 
$text_color = imagecolorallocate($im, 233, 14, 91); 
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color); 
imagepng($im); 
imagedestroy($im);
登入後複製

运行机制时提示:Fatal error: Call to undefined function imagecreate() .....

后面突然想起没打开gd库了,这一问题是,GD库没有正确安装或配置.

解决方案:在php.ini中找到 ;extension=php_gd2.dll 去掉前边的;,然后将php目录中的ext下的php_gd2.dll拷入c:/windows/system32和c:/windows目录下,重启IIS或者apache就OK了.

centos中gd库开启,具体操作只有2个命令如下,运行在线安装带GD库的PHP的命令,代码如下:

yum -y install php-gd

重新启动apachce服务以使安装后的GD库生效,代码如下:

/etc/rc.d/init.d/httpd restart(service httpd restart)

gd的安装路径:

/etc/php.d/gd.ini <---这个是让php支持gd的,这个是CentOS的特色之一,不用把全部东西都写在php.ini这个文件里,只是需要把*.ini文件写在/etc/php.d/文件夹就可以了,系统会自动把这个目录下的*.ini读入php.ini.

/usr/lib/php/modules/gd.so <----这个就是gd的文件.

关于需要使用GD库的图形处理函数还有如下:

gd_info 
getimagesize 
getimagesizefromstring 
image_type_to_extension 
image_type_to_mime_type 
image2wbmp 
imageaffine 
imageaffinematrixconcat 
imageaffinematrixget 
imagealphablending 
imageantialias 
imagearc 
imagechar 
imagecharup 
imagecolorallocate 
imagecolorallocatealpha 
imagecolorat 
imagecolorclosest 
imagecolorclosestalpha 
imagecolorclosesthwb 
imagecolordeallocate 
imagecolorexact 
imagecolorexactalpha 
imagecolormatch 
imagecolorresolve 
imagecolorresolvealpha 
imagecolorset 
imagecolorsforindex 
imagecolorstotal 
imagecolortransparent 
imageconvolution 
imagecopy 
imagecopymerge 
imagecopymergegray 
imagecopyresampled 
imagecopyresized 
&raquo; imagecreate 
imagecreatefromgd2 
imagecreatefromgd2part 
imagecreatefromgd 
imagecreatefromgif 
imagecreatefromjpeg 
imagecreatefrompng 
imagecreatefromstring 
imagecreatefromwbmp 
imagecreatefromwebp 
imagecreatefromxbm 
imagecreatefromxpm 
imagecreatetruecolor 
imagecrop 
imagecropauto 
imagedashedline 
imagedestroy 
imageellipse 
imagefill 
imagefilledarc 
imagefilledellipse 
imagefilledpolygon 
imagefilledrectangle 
imagefilltoborder 
imagefilter 
imageflip 
imagefontheight 
imagefontwidth 
imageftbbox 
imagefttext 
imagegammacorrect 
imagegd2 
imagegd 
imagegif 
imagegrabscreen 
imagegrabwindow 
imageinterlace 
imageistruecolor 
imagejpeg 
imagelayereffect 
imageline 
imageloadfont 
imagepalettecopy 
imagepalettetotruecolor 
imagepng 
imagepolygon 
imagepsbbox 
imagepsencodefont 
imagepsextendfont 
imagepsfreefont 
imagepsloadfont 
imagepsslantfont 
imagepstext 
imagerectangle 
imagerotate 
imagesavealpha 
imagescale 
imagesetbrush 
imagesetinterpolation 
imagesetpixel 
imagesetstyle 
imagesetthickness 
imagesettile 
imagestring 
imagestringup 
imagesx 
imagesy 
imagetruecolortopalette 
imagettfbbox 
imagettftext 
imagetypes 
imagewbmp 
imagewebp 
imagexbm 
iptcembed 
iptcparse 
jpeg2wbmp 
png2wbmp
登入後複製

               
               

本文地址:

转载随意,但请附上文章地址:-)

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

win10打開遊戲fatal error怎麼辦? win10打開遊戲fatal error怎麼辦? Feb 09, 2024 pm 12:54 PM

win10打開遊戲fatalerror怎麼辦?我們在運行軟體或是遊戲的時候會出現提示fatalerror錯誤怎麼辦?下面就讓本站來為用戶們來仔細的介紹一下win10開啟遊戲fatalerror的處理辦法吧。 win10打開遊戲fatalerror怎麼辦?方法一:遊戲客戶端存在了問題,例如檔案的損壞或使用了一些破解補丁,都會導致fatalerror錯誤的出現,大家可以重新下載遊戲。方法二:電腦記憶體太小也會導致fatalerror錯誤的出現,如果是實體記憶體夠的話,那麼可以試著設定一下系統的虛擬內

最終幻想7fatal error怎麼解決 最終幻想7fatal error怎麼解決 Mar 07, 2024 pm 04:40 PM

當玩家在最終幻想7中進行遊戲時,有很多玩家遇到了fatalerror的問題不知道怎麼解決,通常是關於內存不能讀取的問題,建議玩家嘗試重裝遊戲解決。最終幻想7fatalerror怎麼解決1、重裝遊戲遊戲客戶端問題,如檔案損壞,不完整,使用了一些破解補丁都會導致致命錯誤的出現,建議重裝遊戲。 2.把所有檔案屬性的唯讀去掉某些檔案屬性不該是只讀而設定成了唯讀,把所有檔案屬性的唯讀去掉就行了,例如一款遊戲不能玩,那麼右鍵點擊該遊戲的安裝資料夾,取消唯讀屬性。 3.設定虛擬記憶體可能是因為記憶體太小,如果實體記憶體足

PHP Notice: Undefined property: 的解決方法 PHP Notice: Undefined property: 的解決方法 Jun 22, 2023 pm 02:48 PM

在使用PHP編寫程式碼時,我們可能會遇到「Notice:Undefinedproperty」這個錯誤提示。這個錯誤提示意味著我們正在存取一個未定義的屬性,通常是因為該屬性在程式碼中尚未被初始化。那麼,該如何解決這個問題呢?以下是幾種可能的解決方法:初始化屬性這是解決問題的最簡單方法。在程式碼中明確地初始化屬性,可以確保它在使用前已經被定義。例如:class

Vue中的TypeError: Cannot read property '$XXX' of undefined,該如何處理? Vue中的TypeError: Cannot read property '$XXX' of undefined,該如何處理? Nov 25, 2023 pm 12:14 PM

如果你在使用Vue.js進行開發時,經常遇到「TypeError:Cannotreadproperty'$XXX'ofundefined」的錯誤提示,那麼該如何處理呢?本文將介紹這個錯誤的原因以及如何解決。問題的原因在使用Vue.js的時候,我們常常會用this來呼叫Vue元件的方法,例如:exportdefault{data()

undefined和null是什麼意思 undefined和null是什麼意思 Nov 20, 2023 pm 02:39 PM

在JavaScript 中,undefined和null都代表著「無」的概念:1、undefined 表示一個未初始化的變數或一個不存在的屬性,當宣告了一個變數但沒有對其賦值時,這個變數的值就是undefined ,當存取物件中不存在的屬性時,傳回的值也是undefined;2、null表示一個空的物件引用,在某些情況下,可以將物件的引用設為null,以便釋放其佔用的記憶體。

如何解決 golang 中的 'undefined: path.Join” 錯誤? 如何解決 golang 中的 'undefined: path.Join” 錯誤? Jun 24, 2023 pm 01:12 PM

在Go語言中,path套件是處理檔案路徑的重要工具之一。其中path.Join()函數可以將多個路徑組合成一個完整的路徑。但是,有時你會遇到「undefined:path.Join」的錯誤訊息,該怎麼辦呢?以下是幾個常見的解決方法:檢查import語句首先,你需要確認自己已經正確import了path套件。在Go語言中,匯入包時可

null和undefined有什麼不同 null和undefined有什麼不同 Nov 08, 2023 pm 04:43 PM

null和undefined的差異在:1、語意意義;2、使用場景;3、與其它值的比較;4、與全域變數的關係;5、與函數參數的關係;6、可空性檢定;7、性能考慮;8、在JSON序列化中的表現;9、與類型的關係。詳細介紹:1、語意意義,null通常表示知道這個變數不會擁有任何有效的物件值,而undefined則通常表示變數未被賦值,或物件沒有此屬性;2、使用場景等等。

undefined是什麼 undefined是什麼 Jul 31, 2023 pm 02:28 PM

undefined是代表一個值或變數不存在或未定義的狀態。它可以作為預設值來判斷一個變數是否已經被賦值,也可以用來設定預設參數值。儘管在不同的程式語言中,undefined可能具有不同的意義和用法,但理解undefined的概念可以幫助我們更好地理解和編寫程式。

See all articles