![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
Senior Coder ![]() Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
GD - Overlay Watermark
This code overlays a watermark (transparent or not) on to an image using the GD image library. This code would be useful for websites that commonly have pictures uploaded to them and wish to overlay a watermark over them, as this code can be called in a url, thus from img tags. Such as image.php?image=uploaded-343223.jpg. The position of the watermark starts from the bottom right corner, and the offset can easily be configured with the $w_offset and $h_offset variables below.
PHP Code:
__________________
"$question = ( to() ) ? be() : ~be();" Last edited by Velox Letum; 11-12-2005 at 12:41 AM.. |
|
|
|
|
|
PM User | #2 |
|
Administrator ![]() ![]() Join Date: Mar 2002
Location: North America
Posts: 2,418
Thanks: 1
Thanked 13 Times in 13 Posts
![]() |
A short description of what this code does and in what setting would really help.
__________________
- George - JavaScript Kit- JavaScript tutorials and 400+ scripts! - JavaScript Reference- JavaScript reference you can relate to. |
|
|
|
|
|
PM User | #3 |
|
Senior Coder ![]() Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
My apologies, I will be sure to include a description and possible use for scripts in which they are not readily apparent.
__________________
"$question = ( to() ) ? be() : ~be();" |
|
|
|
|
|
PM User | #4 |
|
New Coder ![]() Join Date: Feb 2005
Location: Wasilla, Alaska
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
OMG, thank you so much, you have no idea how long I've been search for a tutorial / script that i can use on my site. This has helped me so much! I really appreciate the snippet you have provided.
__________________
trying to revive an old site... |
|
|
|
|
|
PM User | #6 | |
|
Senior Coder ![]() ![]() Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
__________________
PHP Weekly - A PHP Developers Resource PHP 5.1.4 and Ruby on Rails web hosting Moderator of PHP and Work offers and Requests Install Apache/PHP/MySQL (by marek_mar) | TinyPlugin Architecture |
|
|
|
|
|
|
PM User | #7 | |
|
Senior Coder ![]() Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
__________________
"$question = ( to() ) ? be() : ~be();" |
|
|
|
|
|
|
PM User | #8 |
|
New Coder ![]() Join Date: Mar 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Hi all
I know this was posted a long time ago by Velox Letum but i am after something very similar to this as i require a watermarked image that will overlay the whole page. Having read the post i do not fully understand what is required to be able to use it and where i would put the folders. Any advice would be great and of huge benifit to me. Thanks Richard |
|
|
|
|
|
PM User | #9 |
|
Moderator ![]() ![]() Join Date: Mar 2007
Location: Florida, USA
Posts: 2,529
Thanks: 1
Thanked 223 Times in 216 Posts
![]() ![]() |
Pretty much just PHP, and GD2. You'll probably want to use imagecopyresampled instead of imagecopy. That original script looks like he was keeping the images out of publicly accessible areas and watermarking them on-the-fly as they load in his webpages. That could put a large amount of stress on your server if you have more than a couple of images.
|
|
|
|
|
|
PM User | #10 |
|
Regular Coder ![]() Join Date: Sep 2007
Location: Grahamstown, South Africa
Posts: 125
Thanks: 5
Thanked 7 Times in 7 Posts
![]() |
Instead of using a extention, cant you use getimagesize? eg.
PHP Code:
Im not sure if Im making any sense? Send me back to the loony bin someone. Last edited by idalatob; 09-18-2007 at 01:43 PM.. |
|
|
|
|
|
PM User | #12 |
|
New to the CF scene Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Centred watermark
Thanks for the tips on this page guys. This version does (should do) the following:
1. Load the image and scale it to a given maximum dimension. 2. Load the watermark file 3. Work out the width of the image and the watermark and apply the watermark centrally 4. Create a thumbnail without a watermark but scaled to a given maximum dimension. 5. Save out both thumbnail and watermarked images to file. 6. Delete the orginal file. I did it for me and my needs but it should be pretty easy to tweak. Might help anyone putting up an image library ... PHP Code:
Last edited by simon@vg; 10-19-2007 at 02:51 PM.. Reason: Unclear writing |
|
|
|
|
|
PM User | #13 | |
|
Senior Coder ![]() Join Date: Sep 2005
Location: Sydney, Australia
Posts: 2,275
Thanks: 0
Thanked 23 Times in 22 Posts
![]() |
Quote:
Code:
case 'jpg':
case 'jpeg':
$background = imagecreatefromjpeg($dir . $image);
break;
__________________
Stephen Helping others to solve their computer problem at http://www.felgall.com/ Web related ebooks and software - http://members.felgall.com/ Focus on Javascript - http://javascript.about.com/ |
|
|
|
|
|
|
PM User | #14 | |
|
Senior Coder ![]() Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
__________________
"$question = ( to() ) ? be() : ~be();" |
|
|
|
|
|
|
PM User | #15 |
|
Regular Coder ![]() Join Date: Nov 2006
Posts: 246
Thanks: 13
Thanked 26 Times in 24 Posts
![]() |
For anyone who may want it, here's a way to tile watermark the whole image:
Replace: PHP Code:
PHP Code:
Last edited by Majoracle; 11-20-2007 at 10:43 PM.. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|