Jump to content

[SOLVED] Watermarking images on the fly


gerkintrigg

Recommended Posts

Hello. I'm trying to create a script that re-sizes and watermarks images on the fly for a photo library website. I found a free source code system that I have changed slightly and now works at:

http://build.nextdaygraphics.com/watermark/index.php but:

I need to be able to control the size depending on the use of the image.

I need to be able to control whether there is a watermark added or not.

 

I want it to create the image with a watermark (only one... no point in selecting it for this purpose), re-size it, display it and then delete it so that it's not stored on the server. i know that imagedrestroy() will delete it okay, I have a re-size script that works by parsing the full image URL to the script as a variable, but I don't want to do that in-case someone works out the path to the full image from the source code. Then they could get the images for FREE and my clients wouldn't like that too much ;o)

 

Is there something out there that will do all of this for me or do i need to dig into the code a little more and learn this stuff myself?

 

Thanks.

Neil

Link to comment
https://forums.phpfreaks.com/topic/57729-solved-watermarking-images-on-the-fly/
Share on other sites

i think if you are building websites for money, then, per your last sentence, you need to dig in and learn it yourself.

 

that said, here's what I do for an image i create on the fly that gets resized (to a fixed value of 135x170) and adds a drop shadow image (like a water mark, but its behind the image and a little bit bigger):

 

<?php

$useFile = "/images/file.jpg"; //location of original. 
$dropShadowImage = "/images/dropshadow.jpg";

$srcImage = imagecreatefromjpeg($useFile);
$srcResize = imagecreatetruecolor(135, 179);
imagecopyresampled($srcResize, $srcImage, 0, 0, 0, 0, 135, 179, imagesx($srcImage), imagesy($srcImage));

$dropShadow = imagecreatefromjpeg($dropShadowImage);

header('Content-type: image/jpeg'); // tell browser what type of file this is.
header('Content-Disposition: inline; filename="copyright_gerkintrigg_2007.jpg"'); // send the file name to the browser.

imagecopymerge($dropShadow, $srcResize, 0,0, 0,0, 135, 179, 100);
imagejpeg($dropShadow, null, 100);


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.