欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ThinkPHP做文字水印時(shí)提示call an undefined function exif_imagetype()解決方法

 更新時(shí)間:2014年10月30日 10:32:04   投稿:shichen2014  
這篇文章主要介紹了ThinkPHP做文字水印時(shí)提示call an undefined function exif_imagetype()解決方法,是項(xiàng)目開(kāi)發(fā)中非常實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了ThinkPHP做文字水印時(shí)提示call an undefined function exif_imagetype()解決方法。分享給大家供大家參考。具體如下:

一、問(wèn)題描述:

ThinkPHP做文字水印 ,今天做一個(gè)電子請(qǐng)?zhí)桶炎8UZ(yǔ)貼到圖片上面,發(fā)現(xiàn)一直報(bào)錯(cuò)是取不到圖片類型,比如gif,jpg等,并提示call an undefined function exif_imagetype()。

二、解決方法:

出現(xiàn)這個(gè)錯(cuò)誤就是php.in 配置問(wèn)題,打開(kāi)即可:打開(kāi)擴(kuò)展 extension=php_exif.dll 如果再不行就把extension=php_mbstring.dll ,放到extension=php_exif.dll前邊
注意:extension=php_exif.dll 擴(kuò)展要打開(kāi)
類文件:wptext_class.php代碼如下:

復(fù)制代碼 代碼如下:
<?php
/*
PHP添加文字水印類 V1.0
作者:Yu Tiedun
郵箱:
修改日期:2010-03-07
支持圖片格式:gif, jpg, png
水印的位置自己根據(jù)需要調(diào)整
如能修改得更好,請(qǐng)發(fā)一份給我
*/
class WaterPrint
{
//類開(kāi)始
    public $text, $color, $size, $font, $angle, $px, $py, $im;
//要添加的文字
public function GetWpText($text)
{
   $this->text = $text;
}
//添加文字的顏色
public function GetFtColor($color)
{
   $this->color = $color;
}
//添加文字的字體
public function GetFtType($font)
{
   $this->font = $font;
}
 
//添加文字的大小
public function GetFtSize($size)
{
   $this->size = $size;
}
//文字旋轉(zhuǎn)的角度
public function GetTtAngle($angle)
{
   $this->angle = $angle;
}
//添加文字的位置
public function GetTtPosit()
{
   $this->px = 10;
   $this->py = imagesy($this->im) - 20;
}
//添加文字水印
public function AddWpText($pict)
{
   $ext = exif_imagetype($pict);
    switch ($ext) {
   case 1:
   $picext = "gif";
    $this->im = imagecreatefromgif($pict);
    break;
   case 2:
   $picext = "jpg";
    $this->im = imagecreatefromjpeg($pict);
    break;
   case 3:
   $picext = "png";
    $this->im = imagecreatefrompng($pict);
    break;
   default:
   $this->Errmsg("不支持的文件格式!");
    break;
   }
   //$this->picext = $picext;
   $this->GetTtPosit();
   $im   = $this->im;
   $size = $this->size;
   $angle= $this->angle;
   $px   = $this->px;
   $py   = $this->py;
   $color= $this->color;
   $font = $this->font;
   $text = $this->text;
   $color= imagecolorallocate($im, 255, 0, 0);
   imagettftext($im, $size, $angle, $px, $py, $color, $font, $text);
   switch ($picext) {
   case "gif":
   imagegif($im, $pict);
    break;
   case "jpg":
   imagejpeg($im, $pict, 100);
    break;
   case "png":
      imagealphablending($im, false);
        imagesavealpha($im, true);
       imagepng($im, $pict);
    break;
   }
   imagedestroy($im);
}
//錯(cuò)誤信息提示
public function Errmsg($msg)
{
    echo "<script language='javascript'>alert('".$msg."');</script>";
}
//類結(jié)束
}
?>

調(diào)用頁(yè)面:index.php代碼如下:

復(fù)制代碼 代碼如下:
<?php
header("Content-type: text/html; charset=gbk");
require("wptext_class.php");
$pict = "images/button2.png"; //目標(biāo)圖片
//$text = "XP/Vista/Win7"; //要添加的文字
$text = "文字水印測(cè)試";
$text = iconv("gb2312","utf-8",$text); //防止中文亂碼
$size = 20; //文字大小
$font = "c:/windows/fonts/arial.ttf"; //字體
$angle = 0; //旋轉(zhuǎn)角度,逆時(shí)針
$wptext = new WaterPrint();
$wptext->GetWpText($text);
$wptext->GetFtSize($size);
$wptext->GetFtType($font);
$wptext->GetTtAngle($angle);
$wptext->AddWpText($pict);
$wptext = null;
?>
<a href="images/button2.png" target="_blank">查看結(jié)果</a>

希望本文所述對(duì)大家的ThinkPHP框架程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論