height or if width < height // if so adjust accordingly to make sure the image // stays smaller then the $newWidth and $newHeight $ratioWidth = $srcWidth/$newWidth; $ratioHeight = $srcHeight/$newHeight; if( $ratioWidth < $ratioHeight){ $destWidth = $srcWidth/$ratioHeight; $destHeight = $newHeight; }else{ $destWidth = $newWidth; $destHeight = $srcHeight/$ratioWidth; } if ($resize) { $destImage = ImageCreateTrueColor( $destWidth, $destHeight); } // ImageCopyResized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight ); // better quality but slower: ImageCopyResampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight ); if ($resize == "jpeg") { ImageJPEG( $destImage,"",75 ); } if ($resize == "png") { ImagePNG( $destImage); } ImageDestroy( $srcImage ); ImageDestroy( $destImage ); } /** * Close MySql non-persistent connections */ if (isset($GLOBALS['dbh']) && $GLOBALS['dbh']) { @mysql_close($GLOBALS['dbh']); } if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) { @mysql_close($GLOBALS['userlink']); } ?>