PEJAS Posted February 9, 2011 Share Posted February 9, 2011 I have used the script below to upload and resize images. I have noticed some kinde of LIMITATIONS... • imagecopyresampled & imagecopyresized >>> - image size 3.638 x 3.139 px works fine but not 3.639 x 3.139 or 3.638 x 3.140 px - image size 3.874 x 2.996 px works fine but not 3.875 x 2.996 or 3.874 x 2.997 px - image size 3.335 x 3.335 px is the largest Square images possible to upload and all this is independent of filsize in kb Is there any way to calculate the this limitations? As 3.874x2.996 > 3.638x3.139 this dosen't make any sense As I get the same result with both imagecopyresampled and imagecopyresized what are the real difference? thanks for all help. === SCRIPT ================================================================ //Create image from file $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); // Set a maximum height and width $newwidth = 1280; $newwidth1 = 700; $newwidth2 = 120; $newheight = 1280; $newheight1 = 700; $newheight2 = 120; // Get new dimensions list($width,$height)=getimagesize($uploadedfile); // Set imageratio $ratio = $width/$height; // Set new sizes if ($newwidth/$newheight > $ratio) { $newwidth = $newheight*$ratio; $newwidth1 = $newheight1*$ratio; $newwidth2 = $newheight2*$ratio; } else { $newheight = $newwidth/$ratio; $newheight1 = $newwidth1/$ratio; $newheight2 = $newwidth2/$ratio; } // Resample Resize $tmp = imagecreatetruecolor($newwidth, $newheight); $tmp1= imagecreatetruecolor($newwidth1, $newheight1); $tmp2= imagecreatetruecolor($newwidth2, $newheight2); //imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); //imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); //imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$newheight2,$width,$height); imagecopyresized($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresized($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); imagecopyresized($tmp2,$src,0,0,0,0,$newwidth2,$newheight2,$width,$height); //Save files to folders $filename = "images/". $_FILES['file']['name']; $filename1 = "images/small/". $_FILES['file']['name']; $filename2 = "images/thumbnail/". $_FILES['file']['name']; magejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagejpeg($tmp2,$filename2,100); // Delete tempfiles imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); imagedestroy($tmp2); === SCRIPT ================================================================ Link to comment https://forums.phpfreaks.com/topic/227146-limitations-and-imagecopyresampled-vs-imagecopyresized/ Share on other sites More sharing options...
PEJAS Posted February 9, 2011 Author Share Posted February 9, 2011 Sorry pushed the wrong button! Link to comment https://forums.phpfreaks.com/topic/227146-limitations-and-imagecopyresampled-vs-imagecopyresized/#findComment-1171742 Share on other sites More sharing options...
BlueSkyIS Posted February 9, 2011 Share Posted February 9, 2011 first, i assume that your measurements are in inches, not pixels. as 3.638 x 3.139 px doesn't make sense. (or are you using a . as thousands separator?) anyway: the issue probably comes down to RAM. 2 images of the same pixel dimensions will not necessarily have the same file size. In fact, it would be very rare where 2 different images of the same pixel dimensions have the exact same file size. beyond pixel x pixel, there is the issue of color: how many colors and how much variation of colors from pixel to pixel. a 500 x 500 pixel image of a polar bear in a snowstorm would be far smaller than a 500 x 500 pixel image of the Mona Lisa. in the end, the limit is probably the max memory allowed in php.ini and/or the max available on your server. Link to comment https://forums.phpfreaks.com/topic/227146-limitations-and-imagecopyresampled-vs-imagecopyresized/#findComment-1171863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.