图片加上标签 无 ?phprequire( './WaterMark.class.php' );$water = new WaterMark( './images/psb.jpg', './images/200(1).jpg' );$water-Exec( './images/w.jpg', 'center-center' );? ?php/** * Add water stain to specified image * @author pankai53091
图片加上标签
<?php require( './WaterMark.class.php' ); $water = new WaterMark( './images/psb.jpg', './images/200(1).jpg' ); $water->Exec( './images/w.jpg', 'center-center' ); ?>
<?php /** * Add water stain to specified image * @author pankai<530911044@qq.com> * @date 2013-09-27 */ class WaterMark { /* Image source path */ private $_src_path = NULL; private $_image_source = NULL; /* Water-Stain image source path */ private $_water_path = NULL; private $_water_source = NULL; private $_extension = NULL; public function __construct( $_src_path, $_water_path ) { $this->_src_path = $_src_path; $this->_water_path = $_water_path; } /** * Get image source form image designated path * @param $_img_path * @return resource */ private function getImageSource( $_img_path ) { $_path = explode( ".", strtolower( $_img_path ) ); $_bak = strtoupper( $_path[ sizeof( $_path ) - 1 ] ); $_img_source = NULL; $this->_extension = $_bak; switch( $_bak ) { case "GIF": $_img_source = @imagecreatefromgif( $_img_path ); break; case "JPG": case "JPEG": $_img_source = @imagecreatefromjpeg( $_img_path ); break; case "PNG": $_img_source = @imagecreatefrompng( $_img_path ); break; case "WBMP": $_img_source = @imagecreatefromwbmp( $_img_path ); break; } return $_img_source; } /** * Count coordinate * @param $direction string * @return array */ private function countArgs( &$_src, &$_water, $_direction ) { $_args = NULL; /** * Count the image's width and image's height * which are used to show Water-Stain image arbitrarily */ $src_x = imagesx( $_src ); $src_y = imagesy( $_src ); $water_x = imagesx( $_water ); $water_y = imagesy( $_water ); switch( strtolower( $_direction ) ) { case 'top-left': $_args = array( 0, 0 ); break; case 'top-center': $_args = array( floor( ( $src_x - $water_x ) / 2 ), 0 ); break; case 'top-right': $_args = array( $src_x - $water_x, 0 ); break; case 'center-left': $_args = array( 0, floor( ( $src_y - $water_y ) / 2 ) ); break; case 'center-center': $_args = array( floor( ( $src_x - $water_x ) / 2 ), floor( ( $src_y - $water_y ) / 2 ) ); break; case 'center-right': $_args = array( $src_x - $water_x, floor( ( $src_y - $water_y ) / 2 ) ); break; case 'bottom-left': $_args = array( 0, $src_y - $water_y ); break; case 'bottom-center': $_args = array( floor( ( $src_x - $water_x ) / 2 ), $src_y - $water_y ); break; case 'bottom-right': $_args = array( $src_x - $water_x, $src_y - $water_y ); break; } return $_args; } /** * The main programmer: copy Water-Stain image source into specified image source, * then save this into appointed path * @param $dst_name * @return bool */ public function Exec( $dst_name, $direction = 'bottom-right' ) { $this->_image_source = &$this->getImageSource( $this->_src_path ); $this->_water_source = &$this->getImageSource( $this->_water_path ); $water_x = imagesx( $this->_water_source ); $water_y = imagesy( $this->_water_source ); $_args = $this->countArgs( $this->_image_source, $this->_water_source, $direction ); $_copy = imagecopy( $this->_image_source, $this->_water_source, abs( $_args[ 0 ] ), abs( $_args[ 1 ] ), 0, 0, $water_x, $water_y ); $_out = true; /* imagejpeg( $this->img_dst, $dst_name, 100 ); */ switch ( $this->_extension ) { case 'GIF': $_out = imagegif( $this->_image_source, $dst_name ); break; case 'JPG': case 'JPEG': $_out = imagejpeg( $this->_image_source, $dst_name, 100 ); break; case 'PNG': $_out = imagepng( $this->_image_source, $dst_name ); break; case 'WBMP': $_out = imagewbmp( $this->_image_source, $dst_name ); } return $_copy && $_out; } } ?>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

SublimeText3 Linux新版
SublimeText3 Linux最新版

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中