lukelee Posted January 8, 2009 Share Posted January 8, 2009 Hi, guys, i am making a cms to allow people upload 5 images at once, the problem is when the total size>1.3mb, "fetal error- out of memory" occurs. is there any way to avoid it? my memory limit is 64 and i cant change this number. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/ Share on other sites More sharing options...
lukelee Posted January 8, 2009 Author Share Posted January 8, 2009 Hi, guys, i am making a cms to allow people upload 5 images at once, the problem is when the total size>1.3mb, "fetal error- out of memory" occurs. is there any way to avoid it? my memory limit is 64 and i cant change this number. I think its a common problem, everyone needs a thumbnail function when make cms, isnt it? can someone help? tell me the best way to make a thumbnail function please! Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732324 Share on other sites More sharing options...
xtopolis Posted January 8, 2009 Share Posted January 8, 2009 There are plenty of premade scripts out there. Â I assume your problem is most likely because you're not deleting the images and thumbnails from memory after thumbnailing and saving them to the server. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732328 Share on other sites More sharing options...
lukelee Posted January 8, 2009 Author Share Posted January 8, 2009 There are plenty of premade scripts out there. Â I assume your problem is most likely because you're not deleting the images and thumbnails from memory after thumbnailing and saving them to the server. Â yeah, i got the same answer from another forum, can you please tell me how to delete the images and thumbnails from memory Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732332 Share on other sites More sharing options...
xtopolis Posted January 8, 2009 Share Posted January 8, 2009 imagecreate <?php header("Content-type: image/png"); $im = @imagecreate(110, 20)   or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 0, 0, 0); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); imagepng($im); imagedestroy($im);//OH HI ?> Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732340 Share on other sites More sharing options...
lukelee Posted January 8, 2009 Author Share Posted January 8, 2009 Hi, can you take a look at my code, how to delete the images from memory? and refine my code, I have tried, but didnt work. sorry, i am a nub on php. <?php require_once('db.php'); $title1 = $_POST['title1']; $title2 = $_POST['title2']; $title3 = $_POST['title3']; $title4 = $_POST['title4']; $title5 = $_POST['title5']; $file1 = $_FILES['ufile1']['name']; $file2 = $_FILES['ufile2']['name']; $file3 = $_FILES['ufile3']['name']; $file4 = $_FILES['ufile4']['name']; $file5 = $_FILES['ufile5']['name']; $filesize1=$_FILES['ufile1']['size']; $filesize2=$_FILES['ufile2']['size']; $filesize3=$_FILES['ufile3']['size']; $filesize4=$_FILES['ufile4']['size']; $filesize5=$_FILES['ufile5']['size']; class resizeimage1 {     var $type;     var $width;     var $height;     var $resize_width;     var $resize_height;     var $cut;     var $srcimg;     var $dstimg;     var $im;     function resizeimage1($img, $wid, $hei,$c)     {         $this->srcimg = $img;         $this->resize_width = $wid;         $this->resize_height = $hei;         $this->cut = $c;         $this->type = substr(strrchr($this->srcimg,"."),1);         $this->initi_img();         $this -> dst_img();         $this->width = imagesx($this->im);         $this->height = imagesy($this->im);         $this->newimg();         ImageDestroy ($this->im);     }     function newimg()     {         $resize_ratio = ($this->resize_width)/($this->resize_height);               $ratio = ($this->width)/($this->height);         if(($this->cut)=="1")                 {             if($ratio>=$resize_ratio)                        {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);                            ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)                       {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio));                 ImageJpeg ($newimg,$this->dstimg);                 echo "";             }         }         else             {             if($ratio>=$resize_ratio)             {                 $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height);                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)             {                 $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height);                                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }         }             }            function initi_img()     {         if($this->type=="jpg")         {             $this->im = imagecreatefromjpeg($this->srcimg);         }         if($this->type=="gif")         {             $this->im = imagecreatefromgif($this->srcimg);         }         if($this->type=="png")         {             $this->im = imagecreatefrompng($this->srcimg);         }     }        function dst_img()     {         $full_length = strlen($this->srcimg);         $type_length = strlen($this->type);         $name_length = $full_length-$type_length;         $name    = substr($this->srcimg,0,$name_length-1);         $this->dstimg = $name."_small.".$this->type;         $new_small = basename($this->dstimg);     } } class resizeimage2 {     var $type;     var $width;     var $height;     var $resize_width;     var $resize_height;     var $cut;     var $srcimg;     var $dstimg;     var $im;     function resizeimage2($img, $wid, $hei,$c)     {         $this->srcimg = $img;         $this->resize_width = $wid;         $this->resize_height = $hei;         $this->cut = $c;         $this->type = substr(strrchr($this->srcimg,"."),1);         $this->initi_img();         $this -> dst_img();         $this->width = imagesx($this->im);         $this->height = imagesy($this->im);         $this->newimg();         ImageDestroy ($this->im);     }     function newimg()     {         $resize_ratio = ($this->resize_width)/($this->resize_height);               $ratio = ($this->width)/($this->height);         if(($this->cut)=="1")                 {             if($ratio>=$resize_ratio)                        {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);                            ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)                       {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio));                 ImageJpeg ($newimg,$this->dstimg);                 echo "";             }         }         else             {             if($ratio>=$resize_ratio)             {                 $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height);                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)             {                 $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height);                                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }         }             }            function initi_img()     {         if($this->type=="jpg")         {             $this->im = imagecreatefromjpeg($this->srcimg);         }         if($this->type=="gif")         {             $this->im = imagecreatefromgif($this->srcimg);         }         if($this->type=="png")         {             $this->im = imagecreatefrompng($this->srcimg);         }     }        function dst_img()     {         $full_length = strlen($this->srcimg);         $type_length = strlen($this->type);         $name_length = $full_length-$type_length;         $name    = substr($this->srcimg,0,$name_length-1);         $this->dstimg = $name."_small.".$this->type;         $new_small = basename($this->dstimg);     } } class resizeimage3 {     var $type;     var $width;     var $height;     var $resize_width;     var $resize_height;     var $cut;     var $srcimg;     var $dstimg;     var $im;     function resizeimage3($img, $wid, $hei,$c)     {         $this->srcimg = $img;         $this->resize_width = $wid;         $this->resize_height = $hei;         $this->cut = $c;         $this->type = substr(strrchr($this->srcimg,"."),1);         $this->initi_img();         $this -> dst_img();         $this->width = imagesx($this->im);         $this->height = imagesy($this->im);         $this->newimg();         ImageDestroy ($this->im);     }     function newimg()     {         $resize_ratio = ($this->resize_width)/($this->resize_height);               $ratio = ($this->width)/($this->height);         if(($this->cut)=="1")                 {             if($ratio>=$resize_ratio)                        {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);                            ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)                       {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio));                 ImageJpeg ($newimg,$this->dstimg);                 echo "";             }         }         else             {             if($ratio>=$resize_ratio)             {                 $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height);                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)             {                 $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height);                                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }         }             }            function initi_img()     {         if($this->type=="jpg")         {             $this->im = imagecreatefromjpeg($this->srcimg);         }         if($this->type=="gif")         {             $this->im = imagecreatefromgif($this->srcimg);         }         if($this->type=="png")         {             $this->im = imagecreatefrompng($this->srcimg);         }     }        function dst_img()     {         $full_length = strlen($this->srcimg);         $type_length = strlen($this->type);         $name_length = $full_length-$type_length;         $name    = substr($this->srcimg,0,$name_length-1);         $this->dstimg = $name."_small.".$this->type;         $new_small = basename($this->dstimg);     } } class resizeimage4 {     var $type;     var $width;     var $height;     var $resize_width;     var $resize_height;     var $cut;     var $srcimg;     var $dstimg;     var $im;     function resizeimage4($img, $wid, $hei,$c)     {         $this->srcimg = $img;         $this->resize_width = $wid;         $this->resize_height = $hei;         $this->cut = $c;         $this->type = substr(strrchr($this->srcimg,"."),1);         $this->initi_img();         $this -> dst_img();         $this->width = imagesx($this->im);         $this->height = imagesy($this->im);         $this->newimg();         ImageDestroy ($this->im);     }     function newimg()     {         $resize_ratio = ($this->resize_width)/($this->resize_height);               $ratio = ($this->width)/($this->height);         if(($this->cut)=="1")                 {             if($ratio>=$resize_ratio)                        {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);                            ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)                       {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio));                 ImageJpeg ($newimg,$this->dstimg);                 echo "";             }         }         else             {             if($ratio>=$resize_ratio)             {                 $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height);                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)             {                 $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height);                                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }         }             }            function initi_img()     {         if($this->type=="jpg")         {             $this->im = imagecreatefromjpeg($this->srcimg);         }         if($this->type=="gif")         {             $this->im = imagecreatefromgif($this->srcimg);         }         if($this->type=="png")         {             $this->im = imagecreatefrompng($this->srcimg);         }     }        function dst_img()     {         $full_length = strlen($this->srcimg);         $type_length = strlen($this->type);         $name_length = $full_length-$type_length;         $name    = substr($this->srcimg,0,$name_length-1);         $this->dstimg = $name."_small.".$this->type;         $new_small = basename($this->dstimg);     } } class resizeimage5 {     var $type;     var $width;     var $height;     var $resize_width;     var $resize_height;     var $cut;     var $srcimg;     var $dstimg;     var $im;     function resizeimage5($img, $wid, $hei,$c)     {         $this->srcimg = $img;         $this->resize_width = $wid;         $this->resize_height = $hei;         $this->cut = $c;         $this->type = substr(strrchr($this->srcimg,"."),1);         $this->initi_img();         $this -> dst_img();         $this->width = imagesx($this->im);         $this->height = imagesy($this->im);         $this->newimg();         ImageDestroy ($this->im);     }     function newimg()     {         $resize_ratio = ($this->resize_width)/($this->resize_height);               $ratio = ($this->width)/($this->height);         if(($this->cut)=="1")                 {             if($ratio>=$resize_ratio)                        {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);                            ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)                       {                 $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio));                 ImageJpeg ($newimg,$this->dstimg);                 echo "";             }         }         else             {             if($ratio>=$resize_ratio)             {                 $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height);                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }             if($ratio<$resize_ratio)             {                 $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height);                 imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height);                                 ImageJpeg ($newimg,$this->dstimg);                 echo " ";             }         }             }            function initi_img()     {         if($this->type=="jpg")         {             $this->im = imagecreatefromjpeg($this->srcimg);         }         if($this->type=="gif")         {             $this->im = imagecreatefromgif($this->srcimg);         }         if($this->type=="png")         {             $this->im = imagecreatefrompng($this->srcimg);         }     }        function dst_img()     {         $full_length = strlen($this->srcimg);         $type_length = strlen($this->type);         $name_length = $full_length-$type_length;         $name    = substr($this->srcimg,0,$name_length-1);         $this->dstimg = $name."_small.".$this->type;         $new_small = basename($this->dstimg);     } } $tempimgname1 = strtolower($_FILES["ufile1"][name]); $tempimgname1 = mb_convert_encoding( $tempimgname1, "gb2312", "utf-8"); $filesize1=$_FILES['ufile1']['size']; $tempimgname2 = strtolower($_FILES["ufile2"][name]); $tempimgname2 = mb_convert_encoding( $tempimgname2, "gb2312", "utf-8"); $filesize2=$_FILES['ufile2']['size']; $tempimgname3 = strtolower($_FILES["ufile3"][name]); $tempimgname3 = mb_convert_encoding( $tempimgname3, "gb2312", "utf-8"); $filesize3=$_FILES['ufile3']['size']; $tempimgname4 = strtolower($_FILES["ufile4"][name]); $tempimgname4 = mb_convert_encoding( $tempimgname4, "gb2312", "utf-8"); $filesize4=$_FILES['ufile4']['size']; $tempimgname5 = strtolower($_FILES["ufile5"][name]); $tempimgname5 = mb_convert_encoding( $tempimgname5, "gb2312", "utf-8"); $filesize5=$_FILES['ufile5']['size']; if($filesize1>0) { if(copy($_FILES["ufile1"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname1))){ $image1 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class1 = new resizeimage1("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname1, 110, 110, 1); $s_image1 = basename($class1->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title1','$s_image1','$image1')"); imagedestroy($_FILES["ufile1"]["tmp_name"]); } } if($filesize2>0) { if(copy($_FILES["ufile2"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname2))){ $image2 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class2 = new resizeimage2("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname2, 110, 110, 1); $s_image2 = basename($class2->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title2','$s_image2','$image2')"); imagedestroy($_FILES["ufile2"]["tmp_name"]); } } if($filesize3>0) { if(copy($_FILES["ufile3"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname3))){ $image3 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname3)); $class3 = new resizeimage3("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname3, 110, 110, 1); $s_image3 = basename($class3->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title3','$s_image3','$image3')"); imagedestroy($_FILES["ufile3"]["tmp_name"]); } } if($filesize4>0) { if(copy($_FILES["ufile4"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname4))){ $image4 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname4)); $class4 = new resizeimage4("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname4, 110, 110, 1); $s_image4 = basename($class4->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title4','$s_image4','$image4')"); imagedestroy($_FILES["ufile4"]["tmp_name"]); } } if($filesize5>0) { if(copy($_FILES["ufile5"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname5))){ $image5 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname5)); $class5 = new resizeimage5("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname5, 110, 110, 1); $s_image5 = basename($class5->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title5','$s_image5','$image5')"); imagedestroy($_FILES["ufile5"]["tmp_name"]); } } else { echo "You didn't pick any images." ; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732398 Share on other sites More sharing options...
PFMaBiSmAd Posted January 8, 2009 Share Posted January 8, 2009 Most of your problems are because you are creating 5 different instances of what are probably the same class. Is the definition of each of those classes the same? Â The point of using functions and classes are to reuse one instance of code on different pieces of data. Â If there is nothing different between the definition of those classes (and if there is you should handle the difference using a parameter and conditional logic), just have one definition, create one instance of the class, and call it for each image. Â The class code is already destroying the GD image and the imagedestroy() that you added is operating on the temporary uploaded file, not a GD image resource so it is likely generating an error. Are you developing and testing php code on a system where error_reporting is set to E_ALL and display_errors is set to ON to get php to help you? Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732411 Share on other sites More sharing options...
lukelee Posted January 8, 2009 Author Share Posted January 8, 2009 Most of your problems are because you are creating 5 different instances of what are probably the same class. Is the definition of each of those classes the same? Â The point of using functions and classes are to reuse one instance of code on different pieces of data. Â If there is nothing different between the definition of those classes (and if there is you should handle the difference using a parameter and conditional logic), just have one definition, create one instance of the class, and call it for each image. Â The class code is already destroying the GD image and the imagedestroy() that you added is operating on the temporary uploaded file, not a GD image resource so it is likely generating an error. Are you developing and testing php code on a system where error_reporting is set to E_ALL and display_errors is set to ON to get php to help you? I am using same instance for 5 times because people could upload 5 images at once, if people choose the same file for all 5 images, lets say the image is imageA, imageA will be saved as 1 thumbnail, 1 original image. And i have another function called delete image, people could choose 1 of 5 images to delete, one of the image deleted, the rest of 4 images will be "cant display image", because they are sharing 1 thumbnail, 1 original image. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732460 Share on other sites More sharing options...
lukelee Posted January 8, 2009 Author Share Posted January 8, 2009 I have also tried to use only 1 class, but the same problem still occurs, whats the most common way to make a thumbnail? i feel my way is not correct. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732887 Share on other sites More sharing options...
PFMaBiSmAd Posted January 8, 2009 Share Posted January 8, 2009 whats the most common way to make a thumbnail? Using GD functions to resize the image is how it is normally done. Â What is your current code and what is the actual error message (including the line number of the code it is referring to) as the error might not have anything to do with the resize function. Also, knowing what the actual error is and where it is occurring will help pin point what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-732936 Share on other sites More sharing options...
lukelee Posted January 9, 2009 Author Share Posted January 9, 2009 there is no serious error actually, its just a "out of memory" when i upload a large size image, like 2mb. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-733075 Share on other sites More sharing options...
mapleleaf Posted January 9, 2009 Share Posted January 9, 2009 Try increasing your max upload size to 8mb. It is probably at 2mb. Also are you sure execution time is enough? Default is 30 which ought to be enough Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-733115 Share on other sites More sharing options...
lukelee Posted January 9, 2009 Author Share Posted January 9, 2009 Try increasing your max upload size to 8mb. It is probably at 2mb. Also are you sure execution time is enough? Default is 30 which ought to be enough I didnt set any upload size. Quote Link to comment https://forums.phpfreaks.com/topic/139951-how-to-avoid-out-of-memory-error-when-i-create-a-thumbnail-function/#findComment-733153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.