re: [PHP-WIN] Problems with exec()
| From: | Janne Mårtensgård | Date: | Mon, 28 Aug 2000 12:10:06 +0000 |
| Subject: | re: [PHP-WIN] Problems with exec() | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-2207@lists.php.net to get a copy of this message | ||
Gonzalo Vera wrote:
>Can you post some code? Doesn't sound like exec() but something around
>it.
OK, here goes:
<?
function createThumbnail($source,$thumb)
{
$is = getimagesize($source);
if($is[0] > $is[1])
{
$x = 64;
$fact = 64/$is[0];
$y = $fact * $is[1];
}
else
{
$y = 64;
$fact = 64/$is[1];
$x = $fact * $is[0];
}
copy($source,$thumb);
$fly = exec("c:\\php\\im\\mogrify -geometry ".$x."x".$y."!
".$thumb);
}
function createThumbnailDir($sourcedir)
{
$dir = opendir($sourcedir);
while($file = readdir($dir))
{
if((ereg(".gif$",$file)) || (ereg(".jpg$",$file)))
{
if(!ereg("^thumb_",$file))
{
$thfile = "thumb_".$file;
if(!file_exists($thfile))
{
createThumbnail($sourcedir."\\".$file,$sourcedir."\\".$thfile);
}
}
}
}
}
createThumbnailDir("d:\\inetpub\\wwwroot\\dev\\php\\test");
?>
The code is supposed to go through a specified directory, creating thumbnail
images for any gif or jpeg image.
//janne