4) I'd love to see a PEAR IM module a la PerlMagick (but I haven't even looked yet, so please don't flame me for missing something obvious). One of these days I'll have The Great Rewrite and that will go in then. I'd love to be rid of the system() calls to convert and mogrify.
The closest thing out there at the moment (that I know of) is a PHP extension available through PECL, the PHP extension library. According to the docs, it "provides a wrapper to the ImageMagick/GraphicsMagick library." You can find it and download it at http://pecl.php.net/package/imagick.
Hope that helps.
Al
Or, as was said long ago in this thread, you just use the PHP GD extension, read in the image, write a bit of text to it, then write it back out. You can write a loop that loops through the file sin the directory and does this to all of them.
And because I'm such a nice guy:
#!/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']).'png');
}
}
closedir($dh);
?>
--
paperCrane <Justin Patrin>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php