Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
FuckFame.nl  
#1 Posted : Wednesday, May 23, 2007 5:19:56 AM(UTC)
FuckFame.nl

Rank: Member

Groups: Member
Joined: 12/22/2006(UTC)
Posts: 13

Hi,

Because I had some requests to post the watermark script during the uploadprocess, here it is.

This code works, untill the new version, 4.5, comes out - which has a watermark-option build in.


You can put the folowing quote on top of your upload.php*-file

I have commented out the logme function, as it is my own error-logger function.

Code:
function IUwatermark($TheSourceFile, $TheWatermarkFile, $SaveToFile = NULL) {

/* Image */
$waterimage = @imagecreatefrompng($TheWatermarkFile); // or logme('w00t! Error!'); /* My LOGGER. Commented for Forum */
imageAlphaBlending($waterimage, false);
imageSaveAlpha($waterimage, true);

/* Get image info */
$image_string = @file_get_contents($TheSourceFile); // or logme('Imagefile error: Unable to open');
$image = @imagecreatefromstring($image_string); // or logme('Unknown format');
$imageWidth=imageSX($image);
$imageHeight=imageSY($image);

/* Set image info */
$watermarkWidth=imageSX($waterimage);
$watermarkHeight=imageSY($waterimage);

/* Where will the image be? */
/* Mine: bottomright */
$coordinate_X = ( $imageWidth - 5) - ( $watermarkWidth);
$coordinate_Y = ( $imageHeight - 5) - ( $watermarkHeight);
imagecopy($image, $waterimage, $coordinate_X, $coordinate_Y, 
          0, 0, $watermarkWidth, $watermarkHeight);

/* Output */
if(!($SaveToFile)) header('Content-Type: image/jpeg');
imagejpeg ($image, $SaveToFile, 100);
imagedestroy($image);
imagedestroy($waterimage);
if(!($SaveToFile)) exit;
}

The next part is to call the function.

Now, I did it in, maybe a weird, way. But hey, it still won't affect the uploadprocess-time ;)

First, I will let the ImageUploader, upload the file.

(you can find the meaning of $fileNameEcht here. It's the function which creates random keynames.)

Code:

... while the image is uploading, i give it a new filename
... so this is all before the watermark-process
$fileNameEcht = generateKey(8);
... below, is after the image has been uploaded
$image_location = "FakeDirectory/FakeImages/". $fileNameEcht .".jpg";
$watermark_location = 'myWatermarkImage.png';  // should be in your upload-directory
$save_watermarked_file_to = "FakeDirectory/FakeImages/". $fileNameEcht .".jpg";

Now, to call the function:

Code:
IUwatermark($image_location, $watermark_location, $save_watermarked_file_to);

I am very very sorry for the:

1) bad English

2) bad Code (-markup)

3) bad 'manual'

If anyone wants to edit the post, feel free to do it.

I just created this post, because of the requests I received.

Again, sorry. But, if you need any help, suggestions or anything else..

.. I will try to explain the best I can!

Kinds regards,

- Frank Weima

Edited by user Tuesday, December 18, 2007 3:32:43 AM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.