PHP Thumbnail question.
Posted: Tue Jul 10, 2007 11:55 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have put together a little script thats supposed to take a picture and make it 100 pixels wide and stay in proportion on height. It makes the image the correct size but its only showing a piece of the picture. Please help me with this. Thanks.Code: Select all
function createthumbnail($imagedirectory, $imagename, $thumbdirectory, $thumbwidth, $thumbname)
{
$srcimg = imagecreatefromjpeg("$imagedirectory/$imagename");
$origwidth = imagesx($srcimg);
$origheight = imagesy($srcimg);
$ratio = $origwidth / $thumbwidth;
$thumbheight = $origheight / $ratio;
$thumbimg = imagecreate($thumbwidth, $thumbheight);
imagecopyresized($thumbimg, $srcimg, 0, 0, 0, 0, $thumbwidth, $thumbheight, imagesx($thumbimg), imagesy($thumbimg));
imagejpeg($thumbimg, "$thumbdirectory/$thumbname");
}
createthumbnail("$imagedirectory", "$imagename", "$thumbdirectory", 100, "$thumbname");feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]