在这篇文章中,我们将带领您了解织梦CMS图片页面分离简单办法的全貌,包括织梦图片集如何调用的相关情况。同时,我们还将为您介绍有关DEDECMS织梦重命名更改plus文件夹名称的简单办法、php织梦CM
在这篇文章中,我们将带领您了解织梦CMS 图片页面分离简单办法的全貌,包括织梦图片集如何调用的相关情况。同时,我们还将为您介绍有关DEDECMS织梦重命名更改plus文件夹名称的简单办法、php 织梦CMS图片处理类用法、摘自织梦CMS中的图片处理类、摘自织梦CMS中的图片处理类,摘自织梦cms图片的知识,以帮助您更好地理解这个主题。
本文目录一览:- 织梦CMS 图片页面分离简单办法(织梦图片集如何调用)
- DEDECMS织梦重命名更改plus文件夹名称的简单办法
- php 织梦CMS图片处理类用法
- 摘自织梦CMS中的图片处理类
- 摘自织梦CMS中的图片处理类,摘自织梦cms图片
织梦CMS 图片页面分离简单办法(织梦图片集如何调用)
点评:有时候由于图片过多,而我们又或是为了节约主站流量可以将图片放到另外的服务器或另外的二级域名下,那么这个办法比较简单,不需要该数据库 。
*种实现办法:
办法其实很简单,就是先同步uploads目录,一般用rsync即可,一段时间服务器同步一次
代码如下:
{dede:field.body runphp='yes'}
$str = @me;
$str3 = preg_replace("/src=\"\","src=\"://www.dede58.com/uploads",$str);
@me = $str3;
{/dede:field.body}
当然我们也可以从后台直接替换数据库内容也可以,织梦CMS也提供了这个工具,不用每次替换,生成速度更快。
由此类推我们可以将别的网站的程序也可以这样替换。
本文章网址:http://www.ppssdd.com/code/13840.html。转载请保留出处,谢谢合作!DEDECMS织梦重命名更改plus文件夹名称的简单办法
DEDE有很多漏洞都是出自plus文件夹下的文件,网上有很多挂马工具都有自动扫描网站PLUS目录功能用来匹配漏洞文件,因此为了避免被漏洞入侵,我们可以重命名PLUS文件夹,并将里面无用的文件都清理干净,DEDE重命名PLUS目录需要改动对应关系,办法如下修改inlclude文件夹下common.inc.php 187行
//插件目录,这个目录是用于存放计数器、投票、评论等程序的必要动态程序
$cfg_plus_dir = $cfg_cmspath.'/plus';
然后直接修改这里红色位置的名称就可以了,改成你要的名称 本文章网址:http://www.ppssdd.com/code/10500.html。转载请保留出处,谢谢合作!
php 织梦CMS图片处理类用法
PHP织梦CMS图片处理类,感兴趣的小伙伴,下面一起跟随小编 jb51.cc的小编来看看吧。经测试代码如下:
<?PHP
if(!defined('DEDEINC')) exit('Dedecms');
/**
* 图像处理类
*
* @param
* @author 小编 jb51.cc jb51.cc
**/
class image
{
var $attachinfo;
var $targetfile; //图片路径
var $imagecreatefromfunc;
var $imagefunc;
var $attach;
var $animatedgif;
var $watermarkquality;
var $watermarktext;
var $thumbstatus;
var $watermarkstatus;
// 析构函数,兼容PHP4
function image($targetfile,$cfg_thumb,$cfg_watermarktext,$photo_waterpos,$photo_diaphaneity,$photo_wheight,$photo_wwidth,$cfg_watermarktype,$photo_marktrans,$trueMarkimg,$attach = array())
{
$this->__construct($targetfile,$attach);
}
// 析构函数
function __construct($targetfile,$attach = array())
{
$this->thumbstatus = $cfg_thumb;
$this->watermarktext = $cfg_watermarktext;
$this->watermarkstatus = $photo_waterpos;
$this->watermarkquality = $photo_marktrans;
$this->watermarkminwidth = $photo_wwidth;
$this->watermarkminheight = $photo_wheight;
$this->watermarktype = $cfg_watermarktype;
$this->watermarktrans = $photo_diaphaneity;
$this->animatedgif = 0;
$this->targetfile = $targetfile;
$this->attachinfo = @getimagesize($targetfile);
$this->attach = $attach;
switch($this->attachinfo['mime'])
{
case 'image/jpeg':
$this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : '';
$this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : '';
break;
case 'image/gif':
$this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : '';
$this->imagefunc = function_exists('imagegif') ? 'imagegif' : '';
break;
case 'image/png':
$this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : '';
$this->imagefunc = function_exists('imagepng') ? 'imagepng' : '';
break;
}//为空则匹配类型的函数不存在
$this->attach['size'] = empty($this->attach['size']) ? @filesize($targetfile) : $this->attach['size'];
if($this->attachinfo['mime'] == 'image/gif')
{
$fp = fopen($targetfile,'rb');
$targetfilecontent = fread($fp,$this->attach['size']);
fclose($fp);
$this->animatedgif = strpos($targetfilecontent,'netscape2.0') === false ? 0 : 1;
}
}
/**
* 生成缩略图
*
* @access public
* @param int $thumbwidth 图片宽度
* @param int $thumbheight 图片高度
* @param int $preview 是否预览
* @return void
*/
function thumb($thumbwidth,$thumbheight,$preview = 0)
{
$this->thumb_gd($thumbwidth,$preview);
if($this->thumbstatus == 2 && $this->watermarkstatus)
{
$this->image($this->targetfile,$this->attach);
$this->attach['size'] = filesize($this->targetfile);
}
}
/**
* 图片水印
*
* @access public
* @param int $preview 是否预览
* @return void
*/
function watermark($preview = 0)
{
if($this->watermarkminwidth && $this->attachinfo[0] <= $this->watermarkminwidth && $this->watermarkminheight && $this->attachinfo[1] <= $this->watermarkminheight)
{
return ;
}
$this->watermark_gd($preview);
}
/**
* 使用gd生成缩略图
*
* @access public
* @param int $thumbwidth 图片宽度
* @param int $thumbheight 图片高度
* @param int $preview 是否预览
* @return void
*/
function thumb_gd($thumbwidth,$preview = 0)
{
if($this->thumbstatus && function_exists('imagecreatetruecolor') && function_exists('imagecopyresampled') && function_exists('imagejpeg'))
{
$imagecreatefromfunc = $this->imagecreatefromfunc;
$imagefunc = $this->thumbstatus == 1 ? 'imagejpeg' : $this->imagefunc;
list($imagewidth,$imageheight) = $this->attachinfo;
if(!$this->animatedgif && ($imagewidth >= $thumbwidth || $imageheight >= $thumbheight))
{
$attach_photo = $imagecreatefromfunc($this->targetfile);
$x_ratio = $thumbwidth / $imagewidth;
$y_ratio = $thumbheight / $imageheight;
if(($x_ratio * $imageheight) < $thumbheight)
{
$thumb['height'] = ceil($x_ratio * $imageheight);
$thumb['width'] = $thumbwidth;
}
else
{
$thumb['width'] = ceil($y_ratio * $imagewidth);
$thumb['height'] = $thumbheight;
}
$targetfile = !$preview ? ($this->thumbstatus == 1 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : './watermark_tmp.jpg';
$thumb_photo = imagecreatetruecolor($thumb['width'],$thumb['height']);
imagecopyresampled($thumb_photo,$attach_photo,$thumb['width'],$thumb['height'],$imagewidth,$imageheight);
if($this->attachinfo['mime'] == 'image/jpeg')
{
$imagefunc($thumb_photo,$targetfile,100);
}
else
{
$imagefunc($thumb_photo,$targetfile);
}
$this->attach['thumb'] = $this->thumbstatus == 1 ? 1 : 0;
}
}
}
/**
* 使用gd进行水印
*
* @access public
* @param int $preview 是否预览
* @return void
*/
function watermark_gd($preview = 0)
{
if($this->watermarkstatus && function_exists('imagecopy') && function_exists('imagealphablending') && function_exists('imagecopymerge'))
{
$imagecreatefunc = $this->imagecreatefromfunc;
$imagefunc = $this->imagefunc;
list($imagewidth,$imageheight) = $this->attachinfo;
if($this->watermarktype < 2)
{
$watermark_file = $this->watermarktype == 1 ? DEDEDATA.'/mark/mark.png' : DEDEDATA.'/mark/mark.gif';
$watermarkinfo = @getimagesize($watermark_file);
$watermark_logo = $this->watermarktype == 1 ? @imagecreatefrompng($watermark_file) : @imagecreatefromgif($watermark_file);
if(!$watermark_logo)
{
return ;
}
list($logowidth,$logoheight) = $watermarkinfo;
}
else
{
$Box = @imagettfbBox($this->watermarktext['size'],$this->watermarktext['angle'],$this->watermarktext['fontpath'],$this->watermarktext['text']);
$logowidth = max($Box[2],$Box[4]) - min($Box[0],$Box[6]);
$logoheight = max($Box[1],$Box[3]) - min($Box[5],$Box[7]);
$ax = min($Box[0],$Box[6]) * -1;
$ay = min($Box[5],$Box[7]) * -1;
}
$wmwidth = $imagewidth - $logowidth;
$wmheight = $imageheight - $logoheight;
if(($this->watermarktype < 2 && is_readable($watermark_file) || $this->watermarktype == 2) && $wmwidth > 10 && $wmheight > 10 && !$this->animatedgif)
{
switch($this->watermarkstatus)
{
case 1:
$x = +5;
$y = +5;
break;
case 2:
$x = ($imagewidth - $logowidth) / 2;
$y = +5;
break;
case 3:
$x = $imagewidth - $logowidth - 5;
$y = +5;
break;
case 4:
$x = +5;
$y = ($imageheight - $logoheight) / 2;
break;
case 5:
$x = ($imagewidth - $logowidth) / 2;
$y = ($imageheight - $logoheight) / 2;
break;
case 6:
$x = $imagewidth - $logowidth - 5;
$y = ($imageheight - $logoheight) / 2;
break;
case 7:
$x = +5;
$y = $imageheight - $logoheight - 5;
break;
case 8:
$x = ($imagewidth - $logowidth) / 2;
$y = $imageheight - $logoheight - 5;
break;
case 9:
$x = $imagewidth - $logowidth - 5;
$y = $imageheight - $logoheight -5;
break;
}
$dst_photo = @imagecreatetruecolor($imagewidth,$imageheight);
$target_photo = $imagecreatefunc($this->targetfile);
imagecopy($dst_photo,$target_photo,$imageheight);
if($this->watermarktype == 1)
{
imagecopy($dst_photo,$watermark_logo,$x,$y,$logowidth,$logoheight);
}
elseif($this->watermarktype == 2)
{
if(($this->watermarktext['shadowx'] || $this->watermarktext['shadowy']) && $this->watermarktext['shadowcolor'])
{
$shadowcolorrgb = explode(',',$this->watermarktext['shadowcolor']);
$shadowcolor = imagecolorallocate($dst_photo,$shadowcolorrgb[0],$shadowcolorrgb[1],$shadowcolorrgb[2]);
imagettftext($dst_photo,$this->watermarktext['size'],$x + $ax + $this->watermarktext['shadowx'],$y + $ay + $this->watermarktext['shadowy'],$shadowcolor,$this->watermarktext['text']);
}
$colorrgb = explode(',$this->watermarktext['color']);
$color = imagecolorallocate($dst_photo,$colorrgb[0],$colorrgb[1],$colorrgb[2]);
imagettftext($dst_photo,$x + $ax,$y + $ay,$color,$this->watermarktext['text']);
}
else
{
imagealphablending($watermark_logo,true);
imagecopymerge($dst_photo,$logoheight,$this->watermarktrans);
}
$targetfile = !$preview ? $this->targetfile : './watermark_tmp.jpg';
if($this->attachinfo['mime'] == 'image/jpeg')
{
$imagefunc($dst_photo,$this->watermarkquality);
}
else
{
$imagefunc($dst_photo,$targetfile);
}
$this->attach['size'] = filesize($this->targetfile);
}
}
}
}//End Class
/*** 代码来自小编 jb51.cc(jb51.cc) ***/
摘自织梦CMS中的图片处理类
《:摘自织梦CMS中的图片处理类》要点:
本文介绍了:摘自织梦CMS中的图片处理类,希望对您有用。如果有疑问,可以联系我们。
本文实例讲述了摘自织梦CMS中的图片处理类.分享给大家供大家参考.具体如下:PHP应用
<?PHP if(!defined('DEDEINC')) exit('Dedecms'); /** * 图像处理类 * * @version $Id: image.class.PHP 1 18:10 2010年7月5日Z tianya $ * @package Dedecms.Libraries * @copyright copyright (c) 2007 - 2010,DesDev,Inc. * @license http://help.Dedecms.com/usersguide/license.html * @link http://www.Dedecms.com */ class image { var $attachinfo; var $targetfile; //图片路径 var $imagecreatefromfunc; var $imagefunc; var $attach; var $animatedgif; var $watermarkquality; var $watermarktext; var $thumbstatus; var $watermarkstatus; // 析构函数,兼容PHP4 function image($targetfile,$cfg_thumb,$cfg_watermarktext,$photo_waterpos,$photo_diaphaneity,$photo_wheight,$photo_wwidth,$cfg_watermarktype,$photo_marktrans,$trueMarkimg,$attach = array()) { $this->__construct($targetfile,$attach); } // 析构函数 function __construct($targetfile,$attach = array()) { $this->thumbstatus = $cfg_thumb; $this->watermarktext = $cfg_watermarktext; $this->watermarkstatus = $photo_waterpos; $this->watermarkquality = $photo_marktrans; $this->watermarkminwidth = $photo_wwidth; $this->watermarkminheight = $photo_wheight; $this->watermarktype = $cfg_watermarktype; $this->watermarktrans = $photo_diaphaneity; $this->animatedgif = 0; $this->targetfile = $targetfile; $this->attachinfo = @getimagesize($targetfile); $this->attach = $attach; switch($this->attachinfo['mime']) { case 'image/jpeg': $this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : ''; $this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : ''; break; case 'image/gif': $this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : ''; $this->imagefunc = function_exists('imagegif') ? 'imagegif' : ''; break; case 'image/png': $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : ''; $this->imagefunc = function_exists('imagepng') ? 'imagepng' : ''; break; }//为空则匹配类型的函数不存在 $this->attach['size'] = empty($this->attach['size']) ? @filesize($targetfile) : $this->attach['size']; if($this->attachinfo['mime'] == 'image/gif') { $fp = fopen($targetfile,'rb'); $targetfilecontent = fread($fp,$this->attach['size']); fclose($fp); $this->animatedgif = strpos($targetfilecontent,'netscape2.0') === false ? 0 : 1; } } /** * 生成缩略图 * * @access public * @param int $thumbwidth 图片宽度 * @param int $thumbheight 图片高度 * @param int $preview 是否预览 * @return void */ function thumb($thumbwidth,$thumbheight,$preview = 0) { $this->thumb_gd($thumbwidth,$preview); if($this->thumbstatus == 2 && $this->watermarkstatus) { $this->image($this->targetfile,$this->attach); $this->attach['size'] = filesize($this->targetfile); } } /** * 图片水印 * * @access public * @param int $preview 是否预览 * @return void */ function watermark($preview = 0) { if($this->watermarkminwidth && $this->attachinfo[0] <= $this->watermarkminwidth && $this->watermarkminheight && $this->attachinfo[1] <= $this->watermarkminheight) { return ; } $this->watermark_gd($preview); } /** * 使用gd生成缩略图 * * @access public * @param int $thumbwidth 图片宽度 * @param int $thumbheight 图片高度 * @param int $preview 是否预览 * @return void */ function thumb_gd($thumbwidth,$preview = 0) { if($this->thumbstatus && function_exists('imagecreatetruecolor') && function_exists('imagecopyresampled') && function_exists('imagejpeg')) { $imagecreatefromfunc = $this->imagecreatefromfunc; $imagefunc = $this->thumbstatus == 1 ? 'imagejpeg' : $this->imagefunc; list($imagewidth,$imageheight) = $this->attachinfo; if(!$this->animatedgif && ($imagewidth >= $thumbwidth || $imageheight >= $thumbheight)) { $attach_photo = $imagecreatefromfunc($this->targetfile); $x_ratio = $thumbwidth / $imagewidth; $y_ratio = $thumbheight / $imageheight; if(($x_ratio * $imageheight) < $thumbheight) { $thumb['height'] = ceil($x_ratio * $imageheight); $thumb['width'] = $thumbwidth; } else { $thumb['width'] = ceil($y_ratio * $imagewidth); $thumb['height'] = $thumbheight; } $targetfile = !$preview ? ($this->thumbstatus == 1 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : './watermark_tmp.jpg'; $thumb_photo = imagecreatetruecolor($thumb['width'],$thumb['height']); imagecopyresampled($thumb_photo,$attach_photo,$thumb['width'],$thumb['height'],$imagewidth,$imageheight); if($this->attachinfo['mime'] == 'image/jpeg') { $imagefunc($thumb_photo,$targetfile,100); } else { $imagefunc($thumb_photo,$targetfile); } $this->attach['thumb'] = $this->thumbstatus == 1 ? 1 : 0; } } } /** * 使用gd进行水印 * * @access public * @param int $preview 是否预览 * @return void */ function watermark_gd($preview = 0) { if($this->watermarkstatus && function_exists('imagecopy') && function_exists('imagealphablending') && function_exists('imagecopymerge')) { $imagecreatefunc = $this->imagecreatefromfunc; $imagefunc = $this->imagefunc; list($imagewidth,$imageheight) = $this->attachinfo; if($this->watermarktype < 2) { $watermark_file = $this->watermarktype == 1 ? DEDEDATA.'/mark/mark.png' : DEDEDATA.'/mark/mark.gif'; $watermarkinfo = @getimagesize($watermark_file); $watermark_logo = $this->watermarktype == 1 ? @imagecreatefrompng($watermark_file) : @imagecreatefromgif($watermark_file); if(!$watermark_logo) { return ; } list($logowidth,$logoheight) = $watermarkinfo; } else { $Box = @imagettfbBox($this->watermarktext['size'],$this->watermarktext['angle'],$this->watermarktext['fontpath'],$this->watermarktext['text']); $logowidth = max($Box[2],$Box[4]) - min($Box[0],$Box[6]); $logoheight = max($Box[1],$Box[3]) - min($Box[5],$Box[7]); $ax = min($Box[0],$Box[6]) * -1; $ay = min($Box[5],$Box[7]) * -1; } $wmwidth = $imagewidth - $logowidth; $wmheight = $imageheight - $logoheight; if(($this->watermarktype < 2 && is_readable($watermark_file) || $this->watermarktype == 2) && $wmwidth > 10 && $wmheight > 10 && !$this->animatedgif) { switch($this->watermarkstatus) { case 1: $x = +5; $y = +5; break; case 2: $x = ($imagewidth - $logowidth) / 2; $y = +5; break; case 3: $x = $imagewidth - $logowidth - 5; $y = +5; break; case 4: $x = +5; $y = ($imageheight - $logoheight) / 2; break; case 5: $x = ($imagewidth - $logowidth) / 2; $y = ($imageheight - $logoheight) / 2; break; case 6: $x = $imagewidth - $logowidth - 5; $y = ($imageheight - $logoheight) / 2; break; case 7: $x = +5; $y = $imageheight - $logoheight - 5; break; case 8: $x = ($imagewidth - $logowidth) / 2; $y = $imageheight - $logoheight - 5; break; case 9: $x = $imagewidth - $logowidth - 5; $y = $imageheight - $logoheight -5; break; } $dst_photo = @imagecreatetruecolor($imagewidth,$imageheight); $target_photo = $imagecreatefunc($this->targetfile); imagecopy($dst_photo,$target_photo,$imageheight); if($this->watermarktype == 1) { imagecopy($dst_photo,$watermark_logo,$x,$y,$logowidth,$logoheight); } elseif($this->watermarktype == 2) { if(($this->watermarktext['shadowx'] || $this->watermarktext['shadowy']) && $this->watermarktext['shadowcolor']) { $shadowcolorrgb = explode(',',$this->watermarktext['shadowcolor']); $shadowcolor = imagecolorallocate($dst_photo,$shadowcolorrgb[0],$shadowcolorrgb[1],$shadowcolorrgb[2]); imagettftext($dst_photo,$this->watermarktext['size'],$x + $ax + $this->watermarktext['shadowx'],$y + $ay + $this->watermarktext['shadowy'],$shadowcolor,$this->watermarktext['text']); } $colorrgb = explode(',$this->watermarktext['color']); $color = imagecolorallocate($dst_photo,$colorrgb[0],$colorrgb[1],$colorrgb[2]); imagettftext($dst_photo,$x + $ax,$y + $ay,$color,$this->watermarktext['text']); } else { imagealphablending($watermark_logo,true); imagecopymerge($dst_photo,$logoheight,$this->watermarktrans); } $targetfile = !$preview ? $this->targetfile : './watermark_tmp.jpg'; if($this->attachinfo['mime'] == 'image/jpeg') { $imagefunc($dst_photo,$this->watermarkquality); } else { $imagefunc($dst_photo,$targetfile); } $this->attach['size'] = filesize($this->targetfile); } } } }//End Class
希望本文所述对大家的PHP程序设计有所赞助.
《:摘自织梦CMS中的图片处理类》是否对您有启发,欢迎查看更多与《:摘自织梦CMS中的图片处理类》相关教程,学精学透。小编 jb51.cc为您提供精彩教程。
摘自织梦CMS中的图片处理类,摘自织梦cms图片
摘自织梦cms中的图片处理类,摘自织梦cms图片
本文实例讲述了摘自织梦cms中的图片处理类。分享给大家供大家参考。具体如下:
<?php if(!defined(''DEDEINC'')) exit(''dedecms''); /** * 图像处理类 * * @version $Id: image.class.php 1 18:10 2010年7月5日Z tianya $ * @package DedeCMS.Libraries * @copyright Copyright (c) 2007 - 2010, DesDev, Inc. * @license http://help.dedecms.com/usersguide/license.html * @link http://www.dedecms.com */ class image { var $attachinfo; var $targetfile; //图片路径 var $imagecreatefromfunc; var $imagefunc; var $attach; var $animatedgif; var $watermarkquality; var $watermarktext; var $thumbstatus; var $watermarkstatus; // 析构函数,兼容PHP4 function image($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans,$trueMarkimg, $attach = array()) { $this->__construct($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans,$trueMarkimg, $attach); } // 析构函数 function __construct($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans,$trueMarkimg, $attach = array()) { $this->thumbstatus = $cfg_thumb; $this->watermarktext = $cfg_watermarktext; $this->watermarkstatus = $photo_waterpos; $this->watermarkquality = $photo_marktrans; $this->watermarkminwidth = $photo_wwidth; $this->watermarkminheight = $photo_wheight; $this->watermarktype = $cfg_watermarktype; $this->watermarktrans = $photo_diaphaneity; $this->animatedgif = 0; $this->targetfile = $targetfile; $this->attachinfo = @getimagesize($targetfile); $this->attach = $attach; switch($this->attachinfo[''mime'']) { case ''image/jpeg'': $this->imagecreatefromfunc = function_exists(''imagecreatefromjpeg'') ? ''imagecreatefromjpeg'' : ''''; $this->imagefunc = function_exists(''imagejpeg'') ? ''imagejpeg'' : ''''; break; case ''image/gif'': $this->imagecreatefromfunc = function_exists(''imagecreatefromgif'') ? ''imagecreatefromgif'' : ''''; $this->imagefunc = function_exists(''imagegif'') ? ''imagegif'' : ''''; break; case ''image/png'': $this->imagecreatefromfunc = function_exists(''imagecreatefrompng'') ? ''imagecreatefrompng'' : ''''; $this->imagefunc = function_exists(''imagepng'') ? ''imagepng'' : ''''; break; }//为空则匹配类型的函数不存在 $this->attach[''size''] = empty($this->attach[''size'']) ? @filesize($targetfile) : $this->attach[''size'']; if($this->attachinfo[''mime''] == ''image/gif'') { $fp = fopen($targetfile, ''rb''); $targetfilecontent = fread($fp, $this->attach[''size'']); fclose($fp); $this->animatedgif = strpos($targetfilecontent, ''NETSCAPE2.0'') === false ? 0 : 1; } } /** * 生成缩略图 * * @access public * @param int $thumbwidth 图片宽度 * @param int $thumbheight 图片高度 * @param int $preview 是否预览 * @return void */ function thumb($thumbwidth, $thumbheight, $preview = 0) { $this->thumb_gd($thumbwidth, $thumbheight, $preview); if($this->thumbstatus == 2 && $this->watermarkstatus) { $this->image($this->targetfile, $this->attach); $this->attach[''size''] = filesize($this->targetfile); } } /** * 图片水印 * * @access public * @param int $preview 是否预览 * @return void */ function watermark($preview = 0) { if($this->watermarkminwidth && $this->attachinfo[0] <= $this->watermarkminwidth && $this->watermarkminheight && $this->attachinfo[1] <= $this->watermarkminheight) { return ; } $this->watermark_gd($preview); } /** * 使用gd生成缩略图 * * @access public * @param int $thumbwidth 图片宽度 * @param int $thumbheight 图片高度 * @param int $preview 是否预览 * @return void */ function thumb_gd($thumbwidth, $thumbheight, $preview = 0) { if($this->thumbstatus && function_exists(''imagecreatetruecolor'') && function_exists(''imagecopyresampled'') && function_exists(''imagejpeg'')) { $imagecreatefromfunc = $this->imagecreatefromfunc; $imagefunc = $this->thumbstatus == 1 ? ''imagejpeg'' : $this->imagefunc; list($imagewidth, $imageheight) = $this->attachinfo; if(!$this->animatedgif && ($imagewidth >= $thumbwidth || $imageheight >= $thumbheight)) { $attach_photo = $imagecreatefromfunc($this->targetfile); $x_ratio = $thumbwidth / $imagewidth; $y_ratio = $thumbheight / $imageheight; if(($x_ratio * $imageheight) < $thumbheight) { $thumb[''height''] = ceil($x_ratio * $imageheight); $thumb[''width''] = $thumbwidth; } else { $thumb[''width''] = ceil($y_ratio * $imagewidth); $thumb[''height''] = $thumbheight; } $targetfile = !$preview ? ($this->thumbstatus == 1 ? $this->targetfile.''.thumb.jpg'' : $this->targetfile) : ''./watermark_tmp.jpg''; $thumb_photo = imagecreatetruecolor($thumb[''width''], $thumb[''height'']); imagecopyresampled($thumb_photo, $attach_photo, 0, 0, 0, 0, $thumb[''width''], $thumb[''height''], $imagewidth, $imageheight); if($this->attachinfo[''mime''] == ''image/jpeg'') { $imagefunc($thumb_photo, $targetfile, 100); } else { $imagefunc($thumb_photo, $targetfile); } $this->attach[''thumb''] = $this->thumbstatus == 1 ? 1 : 0; } } } /** * 使用gd进行水印 * * @access public * @param int $preview 是否预览 * @return void */ function watermark_gd($preview = 0) { if($this->watermarkstatus && function_exists(''imagecopy'') && function_exists(''imagealphablending'') && function_exists(''imagecopymerge'')) { $imagecreatefunc = $this->imagecreatefromfunc; $imagefunc = $this->imagefunc; list($imagewidth, $imageheight) = $this->attachinfo; if($this->watermarktype < 2) { $watermark_file = $this->watermarktype == 1 ? DEDEDATA.''/mark/mark.png'' : DEDEDATA.''/mark/mark.gif''; $watermarkinfo = @getimagesize($watermark_file); $watermark_logo = $this->watermarktype == 1 ? @imagecreatefrompng($watermark_file) : @imagecreatefromgif($watermark_file); if(!$watermark_logo) { return ; } list($logowidth, $logoheight) = $watermarkinfo; } else { $box = @imagettfbbox($this->watermarktext[''size''], $this->watermarktext[''angle''], $this->watermarktext[''fontpath''],$this->watermarktext[''text'']); $logowidth = max($box[2], $box[4]) - min($box[0], $box[6]); $logoheight = max($box[1], $box[3]) - min($box[5], $box[7]); $ax = min($box[0], $box[6]) * -1; $ay = min($box[5], $box[7]) * -1; } $wmwidth = $imagewidth - $logowidth; $wmheight = $imageheight - $logoheight; if(($this->watermarktype < 2 && is_readable($watermark_file) || $this->watermarktype == 2) && $wmwidth > 10 && $wmheight > 10 && !$this->animatedgif) { switch($this->watermarkstatus) { case 1: $x = +5; $y = +5; break; case 2: $x = ($imagewidth - $logowidth) / 2; $y = +5; break; case 3: $x = $imagewidth - $logowidth - 5; $y = +5; break; case 4: $x = +5; $y = ($imageheight - $logoheight) / 2; break; case 5: $x = ($imagewidth - $logowidth) / 2; $y = ($imageheight - $logoheight) / 2; break; case 6: $x = $imagewidth - $logowidth - 5; $y = ($imageheight - $logoheight) / 2; break; case 7: $x = +5; $y = $imageheight - $logoheight - 5; break; case 8: $x = ($imagewidth - $logowidth) / 2; $y = $imageheight - $logoheight - 5; break; case 9: $x = $imagewidth - $logowidth - 5; $y = $imageheight - $logoheight -5; break; } $dst_photo = @imagecreatetruecolor($imagewidth, $imageheight); $target_photo = $imagecreatefunc($this->targetfile); imagecopy($dst_photo, $target_photo, 0, 0, 0, 0, $imagewidth, $imageheight); if($this->watermarktype == 1) { imagecopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logowidth, $logoheight); } elseif($this->watermarktype == 2) { if(($this->watermarktext[''shadowx''] || $this->watermarktext[''shadowy'']) && $this->watermarktext[''shadowcolor'']) { $shadowcolorrgb = explode('','', $this->watermarktext[''shadowcolor'']); $shadowcolor = imagecolorallocate($dst_photo, $shadowcolorrgb[0], $shadowcolorrgb[1], $shadowcolorrgb[2]); imagettftext($dst_photo, $this->watermarktext[''size''], $this->watermarktext[''angle''], $x + $ax + $this->watermarktext[''shadowx''], $y + $ay + $this->watermarktext[''shadowy''], $shadowcolor, $this->watermarktext[''fontpath''], $this->watermarktext[''text'']); } $colorrgb = explode('','', $this->watermarktext[''color'']); $color = imagecolorallocate($dst_photo, $colorrgb[0], $colorrgb[1], $colorrgb[2]); imagettftext($dst_photo, $this->watermarktext[''size''], $this->watermarktext[''angle''], $x + $ax, $y + $ay, $color, $this->watermarktext[''fontpath''], $this->watermarktext[''text'']); } else { imagealphablending($watermark_logo, true); imagecopymerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logowidth, $logoheight, $this->watermarktrans); } $targetfile = !$preview ? $this->targetfile : ''./watermark_tmp.jpg''; if($this->attachinfo[''mime''] == ''image/jpeg'') { $imagefunc($dst_photo, $targetfile, $this->watermarkquality); } else { $imagefunc($dst_photo, $targetfile); } $this->attach[''size''] = filesize($this->targetfile); } } } }//End Class
希望本文所述对大家的php程序设计有所帮助。
我们今天的关于织梦CMS 图片页面分离简单办法和织梦图片集如何调用的分享已经告一段落,感谢您的关注,如果您想了解更多关于DEDECMS织梦重命名更改plus文件夹名称的简单办法、php 织梦CMS图片处理类用法、摘自织梦CMS中的图片处理类、摘自织梦CMS中的图片处理类,摘自织梦cms图片的相关信息,请在本站查询。
本文标签: