> I want to resize an image before display it in the window.
> Is there a php fonction which do it ?
>
> Thanks !
>
this will actually resize the photo,
hope it helps,
Craig
/***********************************************************************
**********
Function: resizeImageJPG
Parameters: $forcedwidth = new width of jpeg to be created
$forcedheight = new height of jpeg to be created
$sourcefile = original jpeg that is to be resized
$destfile = new jpeg that is to be created
$imgqual = image quality (0 is best quality, 100 is most compressed)
Returns: true on success, false on failure
Side Effects: creates a new jpeg of $forcedwidth*$forcedheight size
called $destfile
************************************************************************
*********/
function resizeImageJPG($forcedwidth, $forcedheight, $sourcefile,
$destfile, $imgqual) {
$g_imgcomp=100-$imgqual;
$g_srcfile=$sourcefile;
$g_dstfile=$destfile;
$g_fw=$forcedwidth;
$g_fh=$forcedheight;
if (file_exists($g_srcfile)) {
$g_is=getimagesize($g_srcfile);
if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) {
$g_iw=$g_fw;
$g_ih=($g_fw/$g_is[0])*$g_is[1];
}
else {
$g_ih=$g_fh;
$g_iw=($g_ih/$g_is[1])*$g_is[0];
}
$img_src=imagecreatefromjpeg($g_srcfile);
$img_dst=imagecreatetruecolor($g_iw,$g_ih);
$imgCpRES=imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0,
$g_iw, $g_ih, $g_is[0], $g_is[1]);
$imgJPEG=imagejpeg($img_dst, $g_dstfile, $g_imgcomp);
imagedestroy($img_dst);
if ($imgJPEG) {
return true;
}
else{
return false;
}
}
}// end function resizeImageJPG
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php