htaccess以及水印水印、htaccess

由网友(找抽呢.)分享简介:我想知道是否有可能以保护那些从外部加载通过使用添加水印我的主人的图像的.htaccess ?I want to know if it is possible to protect images in my host that are loaded from outside by adding a watermark...

我想知道是否有可能以保护那些从外部加载通过使用添加水印我的主人的图像的.htaccess

I want to know if it is possible to protect images in my host that are loaded from outside by adding a watermark using .htaccess?

也就是说,如果其他网站使用我的形象的网址 https://p.xsw88.cn/allimgs/daicuo/20230902/56.png.jpg 在自己的网站一个img标签。

That is, if another site uses my image URL https://p.xsw88.cn/allimgs/daicuo/20230902/56.png.jpg in a img tag in their own websites.

该计划是当外国请求到达我的主人,我添加水印并将其发送给浏览国外网站的用户。

The plan is the when a foreign request comes to my host, I add a watermark to it and send it to the user browsing the foreign site.

推荐答案

你基本上想要做的,就是先从本教程:

What you basically want to do, is start with this tutorial:

http://www.alistapart.com/articles/hotlinking/

此向您介绍如何重定向来自外部网站的PHP页面图像。然后,您可以使用PHP页面水印图像,像这样的东西:

This shows you how to redirect images that come from external sites to a PHP page. Then, you can use that PHP page to watermark your image, with something like this:

<?php
header('content-type: image/jpeg');
$watermark = imagecreatefrompng('watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($_GET['pic']);
$size = getimagesize($_GET['pic']);
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
阅读全文

相关推荐

最新文章