watermarking

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

watermarking

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

set $imagesource accordingly.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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'];
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I already told you, set $imagesource accordingly.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Replace

Code: Select all

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

Code: Select all

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