Jump to content
xisto Community
BuffaloHelp

Watermark Your Image With Simple Php Script found it on the net

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.


Hi,

I can do that. But I want to watermark images stored in database while displaying on web.


Gajendra

Share this post


Link to post
Share on other sites

And you call that simple! LOL! I am a PHP programer and that is a really advance script... I would never have thought to use that ever... Mmmm... good thinking.. thanks for sharing I might just use it... oh yeah need help with php i am ur guy...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

$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.

Share this post


Link to post
Share on other sites

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/

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thanks for posting the code, I am using it on most of my site.
I was wondering if you guys might have an idea on how to pull watermarking off on a href tag. (click a thumbnail to display the large image)

Here is what I tried

<a href="watermark.php?path=images/image1.jpg"><img src="images/image1_thumbnail.jpg" />

Clicking the link yields the raw gd output similar to this

˙Ř˙ŕJFIF˙ţ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ˙ŰC $.' ",#(7),01444'9=82<.342˙ŰC 2!!22222222222222222222222222222222222222222222222222˙Ŕy "˙Ä ˙Äľ}!1AQa"q2Ą#BąÁRŃđ$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz˘Ł¤ĽŚ§¨ŠŞ˛ł´ľśˇ¸šşÂĂÄĹĆÇČÉĘŇÓÔŐÖ×ŘŮÚáâăäĺćçčéęńňóôőö÷řůú˙Ä ˙Äľw!1AQaq"2BĄąÁ #3RđbrŃ $4á%ń&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz˘Ł¤ĽŚ§¨ŠŞ˛ł´ľśˇ¸šşÂĂÄĹĆÇČÉĘŇÓÔŐÖ×ŘŮÚâăäĺćçčéęňóôőö÷řůú˙Ú?đRćeI0#L #ôŁw§Ě)DÂuöâ83J˙2mëCš4Éó˝hšL\/qÚŹß{ÂůhĄFÍŔ¨ý!É

Thanks,

Sean

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.