Hallo Leute,
da ich Wasserzeichen in einer Galerie (Partybilder eines Clubs) nur bei Vollbild-Anzeigen (Lightbox) integrieren musste und mir keine Erweiterung für Version 2.9.1 bekannt war, möchte ich folgendes nicht vorenthalten:
Wasserzeichen für hochgeladene Bilder
Entsprechend dieser Vorgabe habe ich Contao angepasst:
.htaccess im Hauptverzeichnis
watermark.php im Hauptverzeichnis
Fehlen nur noch die watermark.png bzw. url.png - ebenfalls im Hauptverzeichnis. Läuft.
Grüße,
Matthias
da ich Wasserzeichen in einer Galerie (Partybilder eines Clubs) nur bei Vollbild-Anzeigen (Lightbox) integrieren musste und mir keine Erweiterung für Version 2.9.1 bekannt war, möchte ich folgendes nicht vorenthalten:
Wasserzeichen für hochgeladene Bilder
Entsprechend dieser Vorgabe habe ich Contao angepasst:
.htaccess im Hauptverzeichnis
Code:
## # watermark ## RewriteRule ^(.*)tl_files/galerie/(.*) $1watermark.php?src=tl_files/galerie/$2
PHP-Code:
<?php
/**********************************************
*** Automatic Watermark for Content Images ***
***********************************************
*** ***
*** to be used on any CMS. ***
*** do not forget to alter your .htaccess ***
*** to rewrite the image paths ***
*** to this watermark.php ***
*** ***
*** Author: Thomas 'Fischi!' Fischer, 2010 ***
*** based on an idea by webmastersucks.com ***
*** http://www.fischi.cc/ ***
*** ***
**********************************************/
// set the header to jpg output, and get the url of the image wth the src parameter.
header('Content-type: image/jpeg');
$src = $_GET['src'];
// Check the Imagesize - and insert the right watermark for the right sizes.
// Here on my blog: Thumbnails are processed with a frame and shadow,
// small images with a watermark where just my logo is shown
// and big images with the logo and url. other small images are left untouched.
$origsize = getimagesize($src);
// set the right watermarks
if (eregi("270x170", $src)) {
$watermark = imagecreatefrompng('http://meineseite.de/url.png');
} else if ($origsize[0] < 280 && $origsize[1] < 280) {
$skip = "true";
} else {
$watermark = imagecreatefrompng('http://meineseite.de/watermark.png');
}
// create the temporary image. alter the if parameters,
// if you don't want to process some images, for example transparent png's.
// of course, there should not be too much trouble with content images.
if(eregi('.gif',$src)) {
$image = imagecreatefromgif($src);
} elseif(eregi('.jpeg',$src)||eregi('.jpg',$src)) {
$image = imagecreatefromjpeg($src);
} elseif(eregi('.png',$src)) {
$image = imagecreatefrompng($src);
} else {
exit("Your image is not a gif, jpeg or png image. Sorry.");
}
// just process the image, if a watermark has to be integrated.
if ($skip != "true") {
// watermark sizes. strongly recommended to be computed, not set statically.
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
// get the position of the watermark. calculated from the size of the original image,
// minus the size of the watermark. feel free to adjust these parameters.
// for example, if you want the watermark to be displayed on the top left,
// just set them both to zero. the last parameter (-0) gives you the option of leaving
// a space between the end of the image and the watermark (kind of the margin in css)
$dest_x = $origsize[0] - $watermark_width - 0;
$dest_y = $origsize[1] - $watermark_height - 0;
// putting the watermark on the original image
imagecolortransparent($watermark, imagecolorat($watermark,0,0));
imagecopyresampled($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height);
}
// direct output of the image, as jpg. adjust the last parameter to set the quality.
imagejpeg($image, "", 100);
// cleaning out the temporary files.
imagedestroy($image);
imagedestroy($watermark);
?>Grüße,
Matthias

Kommentar