Part of the EllisLab Network
pMachine Pro has been replaced by ExpressionEngine, our full featured web publishing solution. Please consider upgrading.
You can download pMachine Pro here: Download pMachine Pro  |  Download Language Packs
   
 
Watermark on the Images
Posted: 06 April 2005 06:16 AM   [ Ignore ]  
Summer Student
Total Posts:  13
Joined  2005-04-06

I need in plugin or hack a watermark on images which are shown in a news line. That is that on images there was my watermark automatically as soon as the image gets in a news line. Help please

Profile
 
 
Posted: 07 April 2005 03:58 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  47
Joined  2002-12-19

Watermark Images? (Don’t ask for support PLEASE)

The best way to protect your images is to watermark them.  But that can be a real hassle.  This script will take any image and automatically add a watermark before it is delivered from the server to the person’s browser.  The instructions for using this script are in the comment lines at the top of the script. You can see a sample below.
-----------------------------------------------------------------------------------------

- - Start Script Here - -
<?php
// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file
// where watermark.gif is a mostly transparent gif image with the watermark - goes in the same directory as this script
// where this script is named watermark.php
// call this script with an image tag
// <img src="watermark.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg
$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 = @imagecreatefromgif('watermark.gif');
$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);
imagedestroy($image);
imagedestroy($watermark);
?>
- - End Script Here - -

The script centers the watermark, but can easily be modified to place it along any edge if you would prefer a different location.  For example removing the “/2” in the $startwidth and $startheight variable calculations will put the watermark in the lower right corner.

You can then make the original images inaccessible if you put the following lines in a .htaccess file in the directory with the images:

RewriteEngine On
RewriteRule \.(gif|jpg|png)$ http://yourdomain.com/error.gif [L]

This will redirect any attempt to directly access an image in that directory to the error image specified. 

Profile
 
 
Posted: 07 April 2005 04:40 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  13
Joined  2005-04-06

Thanks huge. perfect worked

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 233, on December 18, 2007 12:04 AM
Total Registered Members: 61042 Total Logged-in Users: 0
Total Topics: 73832 Total Anonymous Users: 0
Total Replies: 398283 Total Guests: 34
Total Posts: 472115    
Members ( View Memberlist )
Newest Members:  akafuriousbozdagLajnermatthinckleykirriewanweiRichard DyckArania JainEspenshawnblanc
Active Members: