Creating black images when trying to create thumbnails

Hi all,

I am a newbie at this. I am trying to create thumbnails. However, it
is only creating black images. The image size was created correctly.
I am using php 5.1.6 and GD 2.0.28. Below is the code that I am
using.
Can any one help?

Thanks,

Alanna

=================================

function createThumbnail($imageDirectory, $imageName,
$thumbDirectory,
$thumbWidth)
{
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);

$thumbHeight 0;
$thumbWidth =100;

if($origWidth > $origHeight && $thumbHeight < $origHeight){
$thumbHeight = $origHeight / ($origWidth / $thumbWidth);
} else if ($origWidth < $origHeight && $thumbWidth < $origWidth)
{
$thumbWidth = $origWidth / ($origHeight / $thumbHeight);
} else {
$thumbWidth = $origWidth;
$thumbHeight = $origHeight;
}
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);

imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0,
$thumbWidth, $thumbHeight, origWidth, $origHeight);
imagejpeg($thumbImg, "$thumbDirectory/$imageName");

}

if(!file_exists("/home/alanna/public_html/pics/thumb/")){
if(!mkdir("/home/alanna/public_html/pics/thumb/"))
{
echo "error making thumbs directory";
}
}

if(file_exists("/home/alanna/public_html/pics/thumb/".
$imagename)){
echo "File already exists";
}
else
{
createThumbnail("/home/alanna/public_html/pics/full/",
$imagename, "/
home/alanna/public_html/pics/thumb/", 100);


}
amsablotny [ So, 11 Februar 2007 19:48 ] [ ID #1625744 ]

Re: Creating black images when trying to create thumbnails

Message-ID: <1171219717.471795.186100 [at] j27g2000cwj.googlegroups.com> from
amsablotny [at] yahoo.com contained the following:

> createThumbnail("/home/alanna/public_html/pics/full/",
>$imagename, "/
>home/alanna/public_html/pics/thumb/", 100);


Where does $imagename get set?
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Geoff Berrow [ Mo, 12 Februar 2007 01:31 ] [ ID #1626695 ]
PHP » alt.php » Creating black images when trying to create thumbnails

Vorheriges Thema: WAMP5, short tags and CLI PHP issue
Nächstes Thema: What's wrong with this