使用php为图像添加

使用php为图像添加

本文介绍了使用php为图像添加“水印”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个用户可以上传图片的网站...I have a website where users may upload images...我需要在图片上传后添加我的徽标(水印)。I need to add my logo (watermark) to the images once they are uploaded.我该怎么办?重要的是水印位于可见的角落,例如,我已经看到了即时生成水印的网站,并将标记放在主图像背景为相同颜色的地方,因此如果您知道我的意思,水印就会突出显示。And it is important that the watermark is in a corner where it will be visible, for example I have seen websites which generates a watermark on the fly, and puts the mark wherever the background of the main image is "the same color" so the watermark sticks out if you know what I mean.有人有一个很好的教程或文章吗? 或者知道php中我需要找到水印位置的任何函数?Anybody have a good tutorial or article about this?Or know of any function in php which I would need to find the position of the watermark?推荐答案 A 好的例子:// Load the stamp and the photo to apply the watermark to$stamp = imagecreatefrompng('stamp.png');$im = imagecreatefromjpeg('photo.jpeg');// Set the margins for the stamp and get the height/width of the stamp image$marge_right = 10;$marge_bottom = 10;$sx = imagesx($stamp);$sy = imagesy($stamp);// Copy the stamp image onto our photo using the margin offsets and the photo// width to calculate positioning of the stamp.imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));// Output and free memoryheader('Content-type: image/png');imagepng($im);imagedestroy($im); 这篇关于使用php为图像添加“水印”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-31 04:34