Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2385 invoked by uid 1010); 26 Nov 2003 19:42:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 2361 invoked by uid 1007); 26 Nov 2003 19:42:14 -0000 Message-ID: <20031126194213.2360.qmail@pb1.pair.com> To: internals@lists.php.net Date: Wed, 26 Nov 2003 11:41:55 -0800 Lines: 64 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Posted-By: 209.223.171.65 Subject: Fatal Error: Allowed memory size From: shashin@madmacs.com ("Shashin") I am using the PHP GD functions to resize my images. I get the following error when trying to resize multiple images. It works for one image. ------------------------------------------------------------------------- Fatal error: Allowed memory size of 20971520 bytes exhausted at (null):0 (tried to allocate 6816 bytes) in file ------------------------------------------------------------------------- PHP Config is ------------------------------------------------------------------------- './configure' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--enable-force-cgi-redirect' '--enable-pic' '--disable-rpath' '--enable-wddx--enable-inline-optimization' '--with-bz2' '--with-curl' '--with-dom=/usr' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-debugger' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--enable-track-vars' '--enable-ucd-snmp-hack' '--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-versioning' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-apxs=/usr/local/apache/bin/apxs' '--enable-trans-sid' '--enable-yp' '--with-mysql=/usr' ------------------------------------------------------------------------- The function i am using is below ------------------------------------------------------------------------- function Resize_Image_File ($Source_File, $Target_File, $Proportionate = "yes", $Target_Height = "60", $Target_Width = "60", $Jpeg_Quality = "75") { // Get the dimensions of the source picture $Picture_Size = getimagesize("$Source_File"); $Source_File_Width = $Picture_Size[0]; $Source_File_Height = $Picture_Size[1]; if (preg_match("/gif/i", $Source_File)) { $Source_File = imagecreatefromgif("$Source_File"); } else if (preg_match("/jpg|jpeg/i", $Source_File)) { $Source_File = imagecreatefromjpeg("$Source_File"); } // end of if statement checking for images. // we will contrain proportions for an image when not specified. if ($Proportionate == "yes") $Target_Height = (int)floor($Source_File_Height * $Target_Width / $Source_File_Width); // Create a new image object $Target_Blank_File = imagecreatetruecolor($Target_Width, $Target_Height); // Resize the original picture and copy it into the just created image object. // We will create a progressive jpeg imageinterlace ($Target_Blank_File,1); $Target_File_Final = imagecopyresampled($Target_Blank_File, $Source_File, 0, 0, 0, 0, $Target_Width, $Target_Height, $Source_File_Width, $Source_File_Height); $Create_JPEG = imagejpeg ($Target_Blank_File, "$Target_File", $Jpeg_Quality); imagedestroy ($Source_File); imagedestroy ($Target_Blank_File); imagedestroy ($Target_File_Final); } // end of function resize image file