Page 1 of 1

watermarking

Posted: Fri Dec 15, 2006 8:20 am
by kpraman
Hello,

I am using this code for watermarking images

Code: Select all

echo $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 = @imagecreatefrompng('watermark.png'); 
$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, "image1/imagepic.jpg"); 
imagedestroy($image); 
imagedestroy($watermark);
i am not able to upload images which are outside the folder.

if i want to use,

Code: Select all

$tmp_name = $_FILES["path"]["tmp_name"];
$name = $_FILES["path"]["name"];
instead of

Code: Select all

$_GET['path']
, what should i do?

Thanx

Posted: Fri Dec 15, 2006 8:28 am
by feyd
set $imagesource accordingly.

Posted: Fri Dec 15, 2006 8:37 am
by kpraman
i am trying to use the form to post images.

Code: Select all

<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="path" />
<input type="submit" value="Submit">
</p>
</form>

Code: Select all

$tmp_name = $_FILES["path"]["tmp_name"];
$name = $_FILES["path"]["name"];
how do i alter the code so that i can use the above code instead of

Code: Select all

$_GET['path'];

Posted: Fri Dec 15, 2006 8:43 am
by feyd
I already told you, set $imagesource accordingly.

Posted: Fri Dec 15, 2006 11:07 am
by dibyendrah
Replace

Code: Select all

echo $imagesource=$_GET['path']; 
with

Code: Select all

$imagesource = $_FILES["path"]["name"];