Jump to content

Image WaterMark


web_master

Recommended Posts

Hi,

 

I got a script for a image Watermark.

 

<?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['src']);  
$size = getimagesize($_GET['src']);  
$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);  

?>

 

It can Use it like this, write to browser link:

http://localhost/fotoneis/test.php?src=photoalbums/1_photoalbum/1_photo_big.jpg

 

And its work perfect.

 

BUT

 

 

how can I use a same script in my script:

 

<?php 
$PhotoBigDestination = 'photoalbums/' . $_GET['AlbID'] . '_photoalbum/' . $_GET['PhotoG'] . '_photo_big.jpg';
if ( file_exists( $PhotoBigDestination ) ) {
		$PhotoBigPrint = '<img src="' . $PhotoBigDestination . '" alt=" " class="BigIMG" /><br /><br />';
}

?>

 

 

If I replace $PhotoBigDestination with $image Ive got print image on the screen like this: "...JFIFCREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality..."

 

<?php 
$PhotoBigDestination = 'photoalbums/' . $_GET['AlbID'] . '_photoalbum/' . $_GET['PhotoG'] . '_photo_big.jpg';


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($PhotoBigDestination);  // HERE IS THE CHANGE $_GET['src'] to $PhotoBigDestination
$size = getimagesize($PhotoBigDestination);  // HERE IS THE CHANGE TOO $_GET['src'] to $PhotoBigDestination
$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);  



if ( file_exists( $PhotoBigDestination ) ) {
		$PhotoBigPrint = '<img src="' . $image . '" alt=" " class="BigIMG" /><br /><br />';
}
?>

 

So, I dont know how can I use the script in my script? :(

 

in advanced thanxs

 

T

 

Link to comment
https://forums.phpfreaks.com/topic/162413-image-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.