热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

摘自织梦CMS中的图片处理类【PHP】

后端开发|php教程织梦CMS,图片处理类后端开发-php教程本文实例讲述了摘自织梦CMS中的图片处理类。分享给大家供大家参考。具体如下:微信商城三级分销源码,vscode电脑卡住

后端开发|php教程摘自织梦CMS中的图片处理类【PHP】
织梦CMS,图片处理类
后端开发-php教程
本文实例讲述了摘自织梦CMS中的图片处理类。分享给大家供大家参考。具体如下:
微信商城三级分销源码,vscode 电脑卡住,如何安装体验ubuntu,tomcat是jsp,Sqlite源ios,ecshop 月结支付插件,前端框架react教程交流,爬虫片源分享,php 输出php,seo是指什么意思,愚人节网站源码,网页代码 没有地址栏等,仿爱奇艺网站模板,父页面获取子页面属性值,作业管理系统 源文件,图片采集程序php源码lzw

__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] watermarkminwidth && $this->watermarkminheight && $this->attachinfo[1] 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) 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 watermarktype == 1 ? DEDEDATA.'/mark/mark.jpg' : DEDEDATA.'/mark/mark.jpg'; $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 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

商业论坛源码,vscode生成c语言,ubuntu 修改ip,tomcat配置部署位置,安卓数据库sqlite3,爬虫恢复,php获取上传文件后缀,雅安seo网络推广方案,全讯网站源码,购票网页模板lzw
采集网站源码什么意思,acm现场赛ubuntu,在土里钻爬虫,php ckfinder,转行seo专员lzw

推荐阅读
  • 本文内容为asp.net微信公众平台开发的目录汇总,包括数据库设计、多层架构框架搭建和入口实现、微信消息封装及反射赋值、关注事件、用户记录、回复文本消息、图文消息、服务搭建(接入)、自定义菜单等。同时提供了示例代码和相关的后台管理功能。内容涵盖了多个方面,适合综合运用。 ... [详细]
  • 基于layUI的图片上传前预览功能的2种实现方式
    本文介绍了基于layUI的图片上传前预览功能的两种实现方式:一种是使用blob+FileReader,另一种是使用layUI自带的参数。通过选择文件后点击文件名,在页面中间弹窗内预览图片。其中,layUI自带的参数实现了图片预览功能。该功能依赖于layUI的上传模块,并使用了blob和FileReader来读取本地文件并获取图像的base64编码。点击文件名时会执行See()函数。摘要长度为169字。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 在project.properties添加#Projecttarget.targetandroid-19android.library.reference.1..Sliding ... [详细]
  • Redis抢票先进先出
    php教程|php手册Redis,抢票,先进,先出,Redis+Thinkphp,php教程-php手册手机端模版源码,vscode怎么写c加加,ubuntu安装.run,tomc ... [详细]
  • dedecms织梦sql基本语法直接调用数据库我们在修改使用织梦cms模板时,会用到很多标签,这是dede自身的数据调用命令,可以调用MYSQL的各种数据。这是非常方便的,当我们想要修改文章的频道、列表与内容摘要,甚至是显示多少列,显示什么统计数据,都可以用这 ... [详细]
  • 2021016a4a8560织梦dedecms模板中怎么显示最近浏览文章列表?我们在制作织梦商城模板的时候经常会仿照shopex或者ecshop模式,在列表dede模板中添加最近浏 ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 手把手教你使用GraphPad Prism和Excel绘制回归分析结果的森林图
    本文介绍了使用GraphPad Prism和Excel绘制回归分析结果的森林图的方法。通过展示森林图,可以更加直观地将回归分析结果可视化。GraphPad Prism是一款专门为医学专业人士设计的绘图软件,同时也兼顾统计分析的功能,操作便捷,可以帮助科研人员轻松绘制出高质量的专业图形。文章以一篇发表在JACC杂志上的研究为例,利用其中的多因素回归分析结果来绘制森林图。通过本文的指导,读者可以学会如何使用GraphPad Prism和Excel绘制回归分析结果的森林图。 ... [详细]
  • 本文介绍了互联网思维中的三个段子,涵盖了餐饮行业、淘品牌和创业企业的案例。通过这些案例,探讨了互联网思维的九大分类和十九条法则。其中包括雕爷牛腩餐厅的成功经验,三只松鼠淘品牌的包装策略以及一家创业企业的销售额增长情况。这些案例展示了互联网思维在不同领域的应用和成功之道。 ... [详细]
  • 首先,给栏目分类表dede_arctype表增加缩略图字段typeimg,用phpMyAdmin或其他数据库管理工具,直接在数据表中添加该字段,或者运行下面的SQL语句:alter ... [详细]
author-avatar
zoey小
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有