Någon som kan förklara varför denna funktion inte fungerar på bilder som är större än 1500-2000 pixlar i bredd?
function scaleImage($userfile_name, $width_size, $userfile_type)
{
///////// Start the thumbnail generation//////////////
$image_stats = GetImageSize("$userfile_name");
$original_height = $image_stats[1];
$original_width = $image_stats[0];
echo "original width: " . $image_stats[0] . " height: " . $image_stats[1];
//if($original_width>=430) {
if($original_width>=$width_size) {
$n_width=$width_size; // Fix the width of the thumb nail images
$ratio = ($original_width / $original_height);
//$n_height=100; // Fix the height of the thumb nail imaage
$n_height = round($n_width / $ratio);
/*
echo "Original height: $original_height<br>";
echo "Ratio: $ratio<br>";
echo "N_width: $n_width<br>";
echo "N_height: $n_height<br>";
*/
$tsrc="$userfile_name"; // Path where thumb nail image will be stored
//echo $tsrc;
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($userfile_name);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$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($userfile_name);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$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 //////////
}
}