I've finally got my upload script to create images, add water marks to them... create seperate thumbs and add picture info to the database.... BUT ... I've come to one speed bump.
I've found there's no why in my script that I can leave the height of the thumbnail size blank... The reason I want the height blank is because, if I upload a file long in height.. it will looked squished when the thumbnail is mabe because the set WxH is 115x80
Here is my function code... what should I change?
In the function code below $dest_y .. defines the height... and $dest_x .. defines the width.
<?
function resizeImage($sSourcefile, $dest_y, $dest_x, $sTargetfile, $jpegqual, $gd) {
global $img;
global $logged_in_user;
if(!(is_readable($sSourcefile))) {
printf("<br /><script language=javascript>alert('Temporary file doesn't exist.');</script><br />");}
else {
touch($sTargetfile);
chmod ($sTargetfile, 0755);
if(!(is_writable($sTargetfile))) {
printf("<br /><script language=javascript>alert('No write-permission to new file.');</script><br />");}
else {
$img_src_size=getimagesize($sSourcefile);
$img_src=imagecreatefromjpeg($sSourcefile);
$img_dst=($gd < 2 ? imagecreate($dest_x,$dest_y) : imagecreatetruecolor($dest_x,$dest_y));// Choose the proper command depending on the gd-lib version
$gd < 2 ? imagecopyresized($img_dst, $img_src, 0, 0, 0, 0, $dest_x, $dest_y, $img_src_size[0], $img_src_size[1]) : imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $dest_x, $dest_y, $img_src_size[0], $img_src_size[1]);
imagejpeg($img_dst, $sTargetfile, $jpegqual);
imagedestroy($img_dst);
imagedestroy($img_src);
if(!(file_exists($sTargetfile))) {
return false; }
else {
return true; }
}
}
}
?>