Welcome Guest ( Log In | Register)



4 Pages V  < 1 2 3 4 >  
Reply to this topicStart new topic
> Watermark Your Image With Simple Php Script, found it on the net
Rating 5 V
galexcd
post Jul 5 2007, 06:50 PM
Post #21


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,074
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



QUOTE(reconraiders @ Jun 23 2007, 10:06 AM) *
Can you name a php script with a ".jpg" extension and have the server parse it as php? I don't like having the source of my pictures as a php file. I don't know just a thing I have. Doesn't seem right. Seems like a security hole too.


unfortunately you cannot do this without modifying some server files, eh... not sure which ones so don't ask me. There is a much easier way of tricking the user into thinking its a regular jpg image when it's really a php file. Make a new folder on your server called name.jpg and inside of it put your php file, but rename it to index.php. In many cases, on websites with dynamic images, you can add /index.php after the image and it will not result in a 404 error, because they use this.
Go to the top of the page
 
+Quote Post
gajendrabang
post Jul 5 2007, 09:22 PM
Post #22


Newbie
*

Group: Members
Posts: 5
Joined: 23-June 07
Member No.: 45,315



QUOTE(alex7h3pr0gr4m3r @ Jul 6 2007, 12:20 AM) *
unfortunately you cannot do this without modifying some server files, eh... not sure which ones so don't ask me. There is a much easier way of tricking the user into thinking its a regular jpg image when it's really a php file. Make a new folder on your server called name.jpg and inside of it put your php file, but rename it to index.php. In many cases, on websites with dynamic images, you can add /index.php after the image and it will not result in a 404 error, because they use this.



Hi,

Thanks for your reply. but my problem is different. I want to make a watermark image while feching the orignal image from database

Go to the top of the page
 
+Quote Post
mattblank
post Jul 9 2007, 10:35 PM
Post #23


Newbie
*

Group: Members
Posts: 2
Joined: 9-July 07
Member No.: 46,230



Hi!

This is a fab script...using it now on my site. However is there a way to position the watermark? Currently it displays in the centre, when preferably I would like the image to be displayed in the bottom right corner.

Does anyone know how to do this?

Thanks!
Matt
Go to the top of the page
 
+Quote Post
jlhaslip
post Jul 10 2007, 02:04 AM
Post #24


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 4,072
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol



QUOTE
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);


If I read and understand the script correctly, adjusting these start points in the script will affect the positioning of the watermark.
As an example, remove the "/2" in the width and height and see where the watermark displays on the image.
Try it and let us know if it works for you.
Go to the top of the page
 
+Quote Post
mattblank
post Jul 10 2007, 07:19 AM
Post #25


Newbie
*

Group: Members
Posts: 2
Joined: 9-July 07
Member No.: 46,230



Hi jlhaslip,

Thanks for that, does the trick nicely! 1 and 1 puts it in the bottom right smile.gif

Many thanks,
Matt

This post has been edited by mattblank: Jul 10 2007, 07:21 AM
Go to the top of the page
 
+Quote Post
iGuest
post Oct 12 2007, 03:00 AM
Post #26


Hail Caesar!
*********************

Group: Members
Posts: 5,876
Joined: 21-September 07
Member No.: 50,369



How to create watermark on pdf files in php? can you provide me php script please.............
thank you!

-siva rama krishna
Go to the top of the page
 
+Quote Post
jlhaslip
post Nov 1 2007, 04:36 AM
Post #27


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 4,072
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol



QUOTE(Trap FeedBacker @ Oct 11 2007, 09:00 PM) *
How to create watermark on pdf files in php? can you provide me php script please.............
thank you!

-siva rama krishna


I use a pdf creation software named cutepdf to enhance my pdf output. Actually, i have the cutepdf paid version, might be the paid version which has all the nice features, but I think the basic, free version can 'stamp' pdf pages, too.

http://www.cutepdf.com/
Go to the top of the page
 
+Quote Post
bishoujo
post Nov 1 2007, 02:19 PM
Post #28


Privileged Member
*********

Group: [HOSTED]
Posts: 513
Joined: 14-September 07
Member No.: 49,954



Great! can't wait to try this out! Thank you!
Go to the top of the page
 
+Quote Post
iGuest
post Dec 4 2007, 11:50 AM
Post #29


Hail Caesar!
*********************

Group: Members
Posts: 5,876
Joined: 21-September 07
Member No.: 50,369



Hello people thank you for this script and as I made one that works for me for watermarking multiple picture on upload .

<?php

$watermarkPath = '/root_path_to_png_watermark/'.$watermark_name.'.png';
$target = '/root_path_to_where_upload_after_watermarking/'.$uploaded_picture_name;
$quality = "100";
$imagesource = '/root_path_to_where_upload_after_watermarking/'.$uploaded_picture_name;
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
$watermarkType = substr($watermarkPath,strlen($watermarkPath)-4,4);
$watermarkType = strtolower($watermarkType);

if($filetype == ".gif")
$image = @imagecreatefromgif($imagesource);
else
if($filetype == ".jpg" || $filetype == "jpeg")
$image = @imagecreatefromjpeg($imagesource);
else
if($filetype == ".png")
$image = @imagecreatefrompng($imagesource);
else
die("a murit nu am scos imaginea");

if(!$image)
die("a murit nu avem imagine");

if($watermarkType == ".gif")
$watermark = @imagecreatefromgif($watermarkPath);
else
if($watermarkType == ".png")
$watermark = @imagecreatefrompng($watermarkPath);
else
die("a murit $watermark nu e");

if(!$watermark)
die("a murit lipsa watermark");

$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/to);
$startheight = (($imageheight - $watermarkheight)/to);
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
imagejpeg($image,$target,$quality);
imagedestroy($image);
imagedestroy($watermark);
?>



Hope this works for you.

-Costin Iordache