Table of Contents
ThinkPHP做文字水印时提示call an undefined function exif_imagetype()解决方法,
Home php教程 php手册 ThinkPHP做文字水印时提示call an undefined function exif_imagetype()解决方法,

ThinkPHP做文字水印时提示call an undefined function exif_imagetype()解决方法,

Jun 13, 2016 am 09:22 AM
thinkphp Solution

ThinkPHP做文字水印时提示call an undefined function exif_imagetype()解决方法,

本文实例讲述了ThinkPHP做文字水印时提示call an undefined function exif_imagetype()解决方法。分享给大家供大家参考。具体如下:

一、问题描述:

ThinkPHP做文字水印 ,今天做一个电子请帖,就把祝福语贴到图片上面,发现一直报错是取不到图片类型,比如gif,jpg等,并提示call an undefined function exif_imagetype()。

二、解决方法:

出现这个错误就是php.in 配置问题,打开即可:打开扩展 extension=php_exif.dll 如果再不行就把extension=php_mbstring.dll ,放到extension=php_exif.dll前边
注意:extension=php_exif.dll 扩展要打开
类文件:wptext_class.php代码如下:

复制代码 代码如下:

/*
PHP添加文字水印类 V1.0
作者:Yu Tiedun
邮箱:
修改日期:2010-03-07
支持图片格式:gif, jpg, png
水印的位置自己根据需要调整
如能修改得更好,请发一份给我
*/
class WaterPrint
{
//类开始
    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;
}
//文字旋转的角度
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);
}
//错误信息提示
public function Errmsg($msg)
{
    echo "";
}
//类结束
}
?>

调用页面:index.php代码如下:

复制代码 代码如下:

header("Content-type: text/html; charset=gbk");
require("wptext_class.php");
$pict = "images/button2.png"; //目标图片
//$text = "XP/Vista/Win7"; //要添加的文字
$text = "文字水印测试";
$text = iconv("gb2312","utf-8",$text); //防止中文乱码
$size = 20; //文字大小
$font = "c:/windows/fonts/arial.ttf"; //字体
$angle = 0; //旋转角度,逆时针
$wptext = new WaterPrint();
$wptext->GetWpText($text);
$wptext->GetFtSize($size);
$wptext->GetFtType($font);
$wptext->GetTtAngle($angle);
$wptext->AddWpText($pict);
$wptext = null;
?>
查看结果

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of third-party interface returning 403 in Node.js environment? How to solve the problem of third-party interface returning 403 in Node.js environment? Mar 31, 2025 pm 11:27 PM

Solve the problem of third-party interface returning 403 in Node.js environment. When we use Node.js to call third-party interfaces, we sometimes encounter an error of 403 from the interface returning 403...

How to solve the problem of 'Undefined array key 'sign'' error when calling Alipay EasySDK using PHP? How to solve the problem of 'Undefined array key 'sign'' error when calling Alipay EasySDK using PHP? Mar 31, 2025 pm 11:51 PM

Problem Description When calling Alipay EasySDK using PHP, after filling in the parameters according to the official code, an error message was reported during operation: "Undefined...

The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? Apr 01, 2025 pm 03:03 PM

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

How to solve the problem of cURL error 77 when connecting to Elasticsearch 8 using ThinkPHP6 and elasticsearch-php clients? How to solve the problem of cURL error 77 when connecting to Elasticsearch 8 using ThinkPHP6 and elasticsearch-php clients? Mar 31, 2025 pm 11:36 PM

Using the ThinkPHP6 framework combined with elasticsearch-php client to operate Elasticsearch...

ThinkPHP6 routing: How to completely obtain URL parameters containing special characters such as Chinese? ThinkPHP6 routing: How to completely obtain URL parameters containing special characters such as Chinese? Apr 01, 2025 pm 02:51 PM

ThinkPHP6 routing parameters are processed in Chinese and complete acquisition. In the ThinkPHP6 framework, URL parameters containing special characters (such as Chinese and punctuation marks) are often processed...

See all articles