Jump to content

[SOLVED] Watermark


WorldDrknss

Recommended Posts

I searched through the forums but the one thread referring to what I need did not receive any replies. What I want to do is scale a watermark to about 1/4 of the original image size. This is because when an image is smaller then the watermark the watermark is the full width and height of the original image.

 

this is what I am currently using to test but will change once I figure out how to scale the watermark.

$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();
$watermark = @imagecreatefromjpeg('index_02.jpg');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);  
$watermarkwidth =  imagesx($watermark) ;
$watermarkheight =  imagesy($watermark) ;
$startwidth = (($imagewidth - $watermarkwidth));
$startheight = (($imageheight - $watermarkheight));
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth , $watermarkheight);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);

Link to comment
https://forums.phpfreaks.com/topic/88150-solved-watermark/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.