0
私はこのスクリプトを使用してクライアントのウェブサイトにウォーターマークを作成していますが、1つのウォーターマークが1つのイメージに適しており、別のイメージには適していないという問題があります。動的な透かしは動作しません。しかしPHPの動的ウォーターマーク
<?php
// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file
// where watermark.gif is a mostly transparent gif image with the watermark - goes in the same directory asthis script
// where this script is named watermark.php
// call this script with an image tag
// <img src="watermark.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg
$imagesource = $_GET['path'];
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);
if (!$image) die();
//This bit is the dynamic bit
if(imagesx($image) <=1100){
$watermark = @imagecreatefromgif('watermark_port.gif');
}elseif(imagesx($image) <=1600 && $imagewidth >1100){
$watermark = @imagecreatefromgif('watermark_lans.gif');
}elseif(imagesx($image) >1600){
$watermark = @imagecreatefromgif('watermark_lans.gif');
};
//End of dynamic code
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth,
$watermarkheight);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
:
肖像
ここ
風景 はスクリプトです。私が望むのは、画像の幅が1100px未満で、ポートレートバージョンを使用していて、その代わりにランドスケープバージョンを使用している場合です。
どのようなアイデアであれ大いに魅力的です。真ん中の1が完全に冗長である
if something
do A
else if something
do B
else
do B
:あなたの "動的な部分は、" 何をしているか
おかげで、
デビッド