> 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);
> ?>

Hey,
You REALLY are a nice guy :-)
Thanks.

-Ryan.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to