|
|
|
| #!/usr/bin/php
<?php
//remember the trailing slash
$dir = '/path/to/files/';
$text = 'www.example.com';
$fontsize = 2;//1 - 5
$dh = opendir($dir);
while(false !== ($file = readdir($dh))) {
if($file[0] != '.') {
echo 'Adding watermark to '.$dir.$file."\n";
$fileinfo = pathinfo($file);
switch(strtolower($fileinfo['extension'])) {
case 'png':
$ih = imagecreatefrompng($dir.$file);
break;
case 'jpg':
case 'jpeg':
case 'jpe':
$ih = imagecreatefromjpeg($dir.$file);
break;
case 'gif':
$ih = imagecreatefromgif($dir.$file);
break;
default:
echo 'I don\'t know what to do with the extension '.$fileinfo['extension']."\n";
break;
}
imagealphablending($ih, true);
$color = imagecolorallocatealpha($ih, 255, 255, 255, 50);
$x = (imagesx($ih) - strlen($text) * imagefontwidth($fontsize)) / 2;
$y = imagesy($ih) - imagefontheight($fontsize) * 1.2;
imagestring($ih, $fontsize, $x, $y, $text, $color);
imagepng($ih, $dir.basename($file, '.'.$fileinfo['extension']).'-watermark.png');
}
}
closedir($dh);
?> | | |
|
| Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality. Categories : PHP, GD image library, Graphics | | | PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP, Graphics, GD image library, Beginner Guides | | | Display a bar chart based on random values. Categories : Graphics, PHP, GD image library, Charts and Graphs | | | Advanced Image WaterMarker Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented | | | Line graphics generation library written in PHP + GD library (spanish comments) Categories : PHP, Graphics, GD image library | | | Simple PHP Bar Graph using GD library Categories : PHP, GD image library, Graphics, Arrays | | | CAPTCHA[Image verification] Categories : PHP, Security, GD image library, Graphics, Sessions | | | Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs | | | A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP, Security, Graphics, GD image library | | | imageMarker v 3.00 with new advanced features Categories : PHP, PHP Classes, Graphics, GD image library | | | Generate image with random number (CAPTCHA) Categories : PHP, GD image library, Graphics, Security | | | Image Generation Class ( PNG Format ) Categories : PHP, GD image library, PHP Classes, Graphics | | | PHP Image Compression using GD library Categories : PHP, Compression, GD image library, Graphics | | | a simple pie-chart in php3 (with gd) Categories : PHP, Graphics, GD image library, Charts and Graphs | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | |
| | | | rupert huz wrote :1042
How exactly do you use this - looks like a good script, but have no idea how to implement it. Needs a few words of instruction.
| |
|
|
|