【PHP根据图片色界在不同位置加水印的方法_php技巧】教程文章相关的互联网学习教程文章

PHP给图片加上图片水印和文字水印实例【代码】【图】

下面给大家分享一下PHP给图片加上图片水印和文字水印实例,这也是网站经常用到的功能,把代码加上去,调用就很简单了。核心代码: 1 function imageWaterMark($groundImage, $waterPos = 0, $waterImage = "", $waterText = "", $textFont = 5, $textColor = "#FF0000") { 2 3 $isWaterImage = FALSE; 4 5 $formatMsg = "暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。"; 6 7 //读取水印文...

在PHP中使用GD,如何在PNG和GIF文件上创建透明的PNG水印? (JPG文件工作正常)【代码】

我有一个图像(让我们称之为原始图像),我想在其上为另一个图像添加水印(让我们称之为徽标).徽标是透明的PNG,而原始图像可以是png,jpg或gif.我有以下代码:function watermarkImage($originalFileContents, $originalWidth, $originalHeight) {$logoImage = imagecreatefrompng('logo.png');imagealphablending($logoImage, true);$logoWidth = imagesx($logoImage); $logoHeight = imagesy($logoImage);$originalImage = imagecre...

如何使用PHP为现有PDF文件添加水印?【代码】

我需要使用PHP为现有的PDF文件添加水印.我在Google上搜索过它,但找不到合适的库. 我找到了创建PDF文件预览缩略图的fpdf库,但我不知道它是否为现有PDF文件添加了水印.任何人都可以建议一个PHP库,而不是显示预览并为现有PDF文件添加水印?解决方法:只是一个使用FPDF和FPDI类的快速示例:function PlaceWatermark($file, $text, $xxx, $yyy, $op, $outdir) {require_once('fpdf.php');require_once('fpdi.php');$name = uniqid();$fon...

php – 以编程方式为视频添加水印

所以我正在寻找一种方法,以编程方式为上传到我网站的视频添加水印.我看过ffmpeg-php然而这不会起作用,因为我使用的是共享linux主机.我想知道是否有人知道我可以通过编程方式为mp4视频添加水印的方式,以及如何使用php中的GD lib. 有没有人成功完成此操作或有没有人知道将在共享主机上工作的实用程序?解决方法:除非他们提供了ffmpepg支持,否则您无法在共享主机上执行此操作. Ffmpeg也必须在启用了vhooks和watermark.so库的情况下进行...

php – 使用codeigniter为图像添加水印【代码】

我一直试图通过codeigniter为图像添加水印,下面是我的代码,图像,调整大小和拇指都在工作,但水印似乎无法正常工作.我实际上已经阅读过这个论坛上的类似帖子,但似乎对我不起作用,也许有些事情做得不对class Upload extends CI_Controller {public function __construct(){parent::__construct();$this->load->model("user_model");/*if($this->user_model->login_status() === FALSE){redirect('main');}*/$this->load->helper("file...

使用php为图像添加水印【代码】

我的网站(以html和php编码完整)包含一项允许某些用户上传图片的功能.使用以下代码调整图片的大小和水印:function watermarkpic($filename) {ini_set('max_input_time', 300);require 'config.php'; $watermark = imagecreatefrompng('watermarknew.png'); $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark);if(preg_match('/[.](jpg)$/', $filename)) { $originalimage = imagecreatefromjpeg($p...

在PNG图像PHP中添加PNG水印【代码】

结果:http://i.stack.imgur.com/p1kVz.png 我正在尝试将PNG复制到另一个PNG,但我不知道为什么他们这样返回<?php // File and new size $filename = 'watermark.png';// Get new sizes list($width, $height) = getimagesize($filename);// Load$resim = 'http://www.petrominpng.com.pg/images/logo_big.png';$ext = end(explode('.', $resim));if($ext == "jpeg" || $ext == "jpg") { $thumb = imagecreatefromjpeg($resim); } ...

php – 如何使用codeigniter上传时在图像的不同位置添加水印?【代码】

我添加了如下代码,在图像中心添加水印:if (!is_dir('assets/uploads_image/')) {mkdir('assets/uploads_image/', 0777, true); } if (!is_dir('assets/uploads_watermark_image/')) {mkdir('assets/uploads_watermark_image/', 0777, true); } $config1['upload_path'] = 'assets/uploads_image/'; $config1['allowed_types'] = 'jpeg|png|jpg|svg'; $this->load->library('upload', $config1); $this->upload->initialize($co...

php – Htaccess和水印【代码】

我想知道是否可以通过使用.htaccess添加水印来保护我的主机中从外部加载的图像? 也就是说,如果另一个站点在他们自己的网站中的img标签中使用我的图像URL http://example.com/1.jpg. 计划是当外国请求来到我的主机时,我向它添加水印并将其发送给浏览外国站点的用户.解决方法:您基本上想要做的是从本教程开始: http://www.alistapart.com/articles/hotlinking/ 这将向您展示如何将来自外部站点的图像重定向到PHP页面.然后,您可以使...

PHP水印【代码】

我正在使用此代码创建水印.$image = '1.jpg';$overlay = 'stamp.png';$opacity = "20";if (!file_exists($image)) {die("Image does not exist.");}// Set offset from bottom-right corner$w_offset = 0;$h_offset = 100;$extension = strtolower(substr($image, strrpos($image, ".") + 1));// Load image from fileswitch ($extension){case 'jpg':$background = imagecreatefromjpeg($image);break;case 'jpeg':$background = ...

php-图片加水印和文字

//************************** 图片加文字 ************************ $dst_path = 11.jpg;//创建图片的实例$dst = imagecreatefromstring(file_get_contents($dst_path));//打上文字echo 13;//$font = ./simsun.ttc;//字体$black = imagecolorallocate($dst, 0x00, 0x00, 0x00);//字体颜色echo 12; $font_file = ./arial.ttf; // Draw the text PHP Manual using font size 13imagefttext($dst, 13, 0, 105, 55, $black, $font_fil...

ThinkPHP5 添加多个文字水印及疑难解答【代码】

public function imageload(){$imgpath = ROOT_PATH . public . DS . static . DS . www . DS . img . DS . certificate.png;$ttfpath = ROOT_PATH . public . DS . static . DS . www . DS . fonts . DS . msyh.ttf;$image = \think\Image::open($imgpath);// 给原图左上角添加水印并保存water_image.png$image->text("这是内容1", $ttfpath, 14, #000000,[400,377])->text("这是内容1", $ttfpath, 14, #000000,[400,435])->text(...