I have a form which uploads a image and this will save it then reszie it... problem is most of the images are not very clear.. is there something wrong with the script of is there something else i could do to help make these images clearer?
Orig Size of a pic
Mid Size code with code, this is not as clear
<?php
mysql_connect (localhost, **, **);
mysql_select_db (**);
$result2 = mysql_query ("SELECT * from trips order by id desc limit 1");
$row2 = mysql_fetch_array($result2);
$name = $row2[id] + 1;
$type = ".jpg";
$add="../album/$name$type";
if(move_uploaded_file ($userfile, $add)){
echo "Successfully uploaded the mage";
chmod("$add",0777);
}else{echo "Failed to upload file Contact Site admin to fix the problem";
exit;}
///////// Start the thumbnail generation//////////////
$tsrc="../album/thumbs/$name$type"; // Path where thumb nail image will be stored
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$userfile_type=="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
if ($hight == '2592' && $width == '1944') {
$n_width = 75;
$n_height = 100;
} elseif ($height == '1600' && $width == '1200') {
$n_width = 75;
$n_height = 100;
} elseif ($height == '1024' && $width == '768') {
$n_width = 75;
$n_height = 100;
} elseif ($height == '640' && $width == '480') {
$n_width = 75;
$n_height = 100;
} elseif ($width == '2592' && $height == '1944') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '1600' && $height == '1200') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '1024' && $height == '768') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '640' && $height == '480') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '648' && $height == '486') {
$n_width = 100;
$n_height = 75;
} else {
$n_width = 100;
$n_height = 100;
}
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////
////////////// starting of JPG thumb nail creation//////////
if($userfile_type=="image/pjpeg"){
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
if ($hight == '2592' && $width == '1944') {
$n_width = 75;
$n_height = 100;
} elseif ($height == '1600' && $width == '1200') {
$n_width = 75;
$n_height = 100;
} elseif ($height == '1024' && $width == '768') {
$n_width = 75;
$n_height = 100;
} elseif ($height == '640' && $width == '480') {
$n_width = 75;
$n_height = 100;
} elseif ($width == '2592' && $height == '1944') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '1600' && $height == '1200') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '1024' && $height == '768') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '640' && $height == '480') {
$n_width = 100;
$n_height = 75;
} elseif ($width == '648' && $height == '486') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '648' && $width == '486') {
$n_width = 75;
$n_height = 100;
} elseif ($width == '800' && $height == '600') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '800' && $width == '600') {
$n_width = 75;
$n_height = 100;
} else {
$n_width = 100;
$n_height = 100;
}
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
//////////////// End of JPG thumb nail creation //////////
///////// Start the Mid generation//////////////
$vsrc="../album/mid/$name$type"; // Path where thumb nail image will be stored
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF Mid creation///////////
if (@$userfile_type=="image/gif")
{
$imm=ImageCreateFromGIF($add);
$width2=ImageSx($imm); // Original picture width is stored
$height2=ImageSy($imm); // Original picture height is stored
if ($width2 == '2592' && $height2 == '1944') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($width2 == '1600' && $height2 == '1200') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($width2 == '1024' && $height2 == '768') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($width2 == '640' && $height2 == '480') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '1600' && $width2 == '1200') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($height2 == '1024' && $width2 == '768') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($height2 == '640' && $width2 == '480') {
$n_width2 = 450;
$n_height2 = 600;
} else {
$n_width2 = 500;
$n_height2 = 500;
}
$newimage2=imagecreatetruecolor($n_width2,$n_height2);
imageCopyResized($newimage2,$im,0,0,0,0,$n_width2,$n_height2,$width2,$height2);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage2,$vsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage2,$vsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////
////////////// starting of JPG Mid creation//////////
if($userfile_type=="image/pjpeg"){
$imm=ImageCreateFromJPEG($add);
$width2=ImageSx($imm); // Original picture width is stored
$height2=ImageSy($imm); // Original picture height is stored
if ($width2 == '2592' && $height2 == '1944') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($width2 == '1600' && $height2 == '1200') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($width2 == '1024' && $height2 == '768') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($width2 == '640' && $height2 == '480') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '1600' && $width2 == '1200') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($height2 == '1024' && $width2 == '768') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($height2 == '640' && $width2 == '480') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($height2 == '648' && $width2 == '486') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($width2 == '648' && $height2 == '486') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '800' && $width2 == '600') {
$n_width2 = 450;
$n_height2 = 600;
} elseif ($width2 == '800' && $height2 == '600') {
$n_width2 = 600;
$n_height2 = 450;
} else {
$n_width2 = 100;
$n_height2 = 100;
}
$newimage2=imagecreatetruecolor($n_width2,$n_height2);
imageCopyResized($newimage2,$imm,0,0,0,0,$n_width2,$n_height2,$width2,$height2);
ImageJpeg($newimage2,$vsrc);
chmod("$tsrc",0777);
}
//////////////// End of JPG Mid creation //////////
mysql_connect (localhost, **, **);
mysql_select_db (**);
$filename = $name . $type;
echo $filename;
$date = "$D3-$D2-$D1";
$result = mysql_query ("INSERT INTO trips (`id`,`taken`,`thumb`,`main`,`mid`,`detail`,`shdetail`,`trip_id`,`location`,`private`,`date`) Values('','$taken','$filename','$filename','$filename','$detail','$shdetail','$trip_id','$location','$private','$date')") or die("INSERT error: ".mysql_error());
?>
</body>
<font size="2" face="verdana"><a href="addimg.php">Add Another</a>
</html>