php图片处理:加水
图片处理:加水
废话不说了,虚拟主机,贴代码:
复制代码 代码如下:
/************************************
//函数: watermark($bigimg, $smallimg, $coord = 1)
//作用: 添加水印
//参数:
$bigimg 必选。大图片--要加上水印的图片
$smallimg 必选。小图片
$coord 可选。水印在大图中的位置,
1 左上角; 2 右上角; 3 右下角; 4 左下角; 5 中间
//示例: watermark('datu.png', 'xiaotu.png', 3); //给datu.png打上水印,水印位置在右下角
*************************************/
function watermark($bigimg, $smallimg, $coord = 1){
//载入两张图片,并转成php识别的编码格式,香港服务器,
//等同于 imagecreate 函数,香港服务器,只不过这里创建的不是一个空图片。
$bi = getimagesize($bigimg);
switch($bi[2]){
case 1:
$im1 = imagecreatefromgif($bigimg);break;
case 2;
$im1 = imagecreatefromjpeg($bigimg);break;
case 3;
$im1 = imagecreatefrompng($bigimg);break;
}
$si = getimagesize($smallimg);
switch($si[2]){
case 1:
$im2 = imagecreatefromgif($smallimg);break;
case 2;
$im2 = imagecreatefromjpeg($smallimg);break;
case 3;
$im2 = imagecreatefrompng($smallimg);break;
}
// 创建水印--原理:复制小图到大图上。这里注意坐标值的计算
switch($coord){
case 1:
imagecopy ( $im1, $im2, 0, 0, 0, 0, $si[0], $si[1] ); break;
case 2:
imagecopy ( $im1, $im2, $bi[0]-$si[0], 0, 0, 0, $si[0], $si[1] ); break;
case 3:
imagecopy ( $im1, $im2, $bi[0]-$si[0], $bi[1]-$si[1], 0, 0, $si[0], $si[1] ); break;
case 4:
imagecopy ( $im1, $im2, 0, $bi[1]-$si[1], 0, 0, $si[0], $si[1] ); break;
case 5:
imagecopy ( $im1, $im2, ($bi[0]-$si[0])/2, ($bi[1]-$si[1])/2, 0, 0, $si[0], $si[1] ); break;
}
//根据后缀名生成不同格式的图片文件
switch($bi[2]){
case 1:
imagegif($im1);break;
case 2;
imagejpeg($im1);break;
case 3;
imagepng($im1);break;
}
imagedestroy($im1);
}
/************************************************
//函数: thumbnail($srcimg, $multiple)
//作用: 生成一张缩略图
//参数:
// $srcimg 必选。源图片文件名
// $multiple 可选。缩略倍数,默认为2倍,即缩小为原来的1/2
//注意: 只支持gif、jpg、png的格式图片。
//示例: thumbnail('我的图片.jpg', 5);
*************************************************/
function thumbnail($srcimg, $multiple = 2){
//载入图片并保存其信息到数组
$srcimg_arr = getimagesize($srcimg);
//计算缩略倍数
$thumb_width = $srcimg_arr[0] / $multiple;
$thumb_height = $srcimg_arr[1] / $multiple;
//判断:要建立什么格式的图片(转成php识别的编码)
switch($srcimg_arr[2]){
case 1:
$im = imagecreatefromgif($srcimg);break;
case 2;
$im = imagecreatefromjpeg($srcimg);break;
case 3;
$im = imagecreatefrompng($srcimg);break;
}
//开始缩略操作
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresized($thumb, $im, 0, 0, 0 ,0, $thumb_width, $thumb_height, $srcimg_arr[0], $srcimg_arr[1]);
switch($srcimg_arr[2]){
case 1:
imagegif($thumb); break;
case 2;
imagejpeg($thumb); break;
case 3;
imagepng($thumb); break;
}
imagepng($thumb);
imagedestroy($thumb);
}
//测试 时不要同时使用这两个函数。
//watermark('datu.png','xiaotu.png',5);
thumbnail('abc.png',3);
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This article will introduce how to turn off the thumbnail function displayed when the mouse moves the taskbar icon in Win11 system. This feature is turned on by default and displays a thumbnail of the application's current window when the user hovers the mouse pointer over an application icon on the taskbar. However, some users may find this feature less useful or disruptive to their experience and want to turn it off. Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another drawback is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. but

Windows 1122H2 is the first feature update for Windows 11 and should bring a ton of new features and much-needed improvements. One of the improvements is the ability to preview folder thumbnails of files within a folder. If you don't like the look of folder thumbnails in Windows 11, here's how you can change it. A set of custom icons for folder thumbnails in Windows 11 (courtesy of Reddit's LEXX911) that lets you zoom in on previews and change folder icon styles. You still have to deal with individual file previews (in Windows 7, for example, folder thumbnails can display multiple images at the same time), but you can make it larger and more convenient. important hint:

1. First enter Visual Studio Code and click [File] in the upper left corner. 2. Then click [Preferences]. 3. Click the [Settings] item. 4. Then click [Text Editor-Thumbnail]. 5. Finally, in the thumbnail item, turn on [Control whether to display thumbnails].

With the development of the Internet, pictures have become an indispensable part of web pages. But as the number of images increases, the loading speed of images has become a very important issue. In order to solve this problem, many websites use thumbnails to display images, but in order to generate thumbnails, we need to use professional image processing tools, which is a very troublesome thing for some non-professionals. Then, using JavaScript to achieve automatic thumbnail generation becomes a good choice. How to use JavaS

I often encounter customers who say that a few minor computer problems are very troublesome at critical times. In summary, there are the following. The reason why the file cannot be copied to the USB flash drive may be that the partition format of the USB flash drive is FAT32 instead of NTFS. You can try changing the partition format of the USB flash drive to NTFS so that you can copy large files. Second, the pictures are not displayed as thumbnails, so you have to click on them one by one to find them. The third type is that the page suddenly becomes larger or smaller. If you don’t know these three situations, they can be solved with a few simple operations. 1. Change the U disk partition to NTFS. The default partition format of a newly purchased U disk is generally FAT32. Under normal circumstances, there is no problem in using it. However, when you need to copy files larger than 4G, a prompt that cannot be copied will appear, which brings some trouble to use. for

1. In the [Picture Beautification] function of MeituXiuXiu, upload or select the picture you want to add a watermark to. 2. Click the [Text] option on the bottom toolbar, enter the watermark content and adjust its color, size and transparency. 3. Adjust the size and position of the watermark, and click [Finish] to confirm editing after confirming that you are satisfied. 4. Finally, click the [Save] button in the upper right corner to save the image with the watermark.

Detailed explanation of the steps to generate thumbnails with PHP, specific code examples are required. In today's era of rapid Internet development, pictures are an indispensable part of web pages, but high-resolution pictures will not only take up a lot of bandwidth, but also affect the user's web page loading. speed. Therefore, we often need to generate thumbnails from original images to reduce image size and file size. As a popular server-side scripting language, PHP provides rich image processing functions that can be used to generate thumbnails. The following will introduce in detail the steps to generate thumbnails in PHP.

Tables in PowerPoint presentations help display data in a structured format when you present. The numbers shown in the table have a better impact on the audience. Microsoft Powerpoint has several ways to add tables to your presentations. You can choose to add a new table or copy from an existing table in another application such as Excel or Word. Method 1: Insert a table by selecting rows and columns on the grid Step 1: On the PowerPoint thumbnail, right-click Master Slide and select New Slide. Step 2: Go to Insert and click Table. Step 3: From the drop-down menus, select the total number of rows and columns required for the table. Notice
