GregL83 Posted April 18, 2009 Share Posted April 18, 2009 I created an image handling script. So far it works well; however, when I try to upload a bitmap / bmp file all hell breaks loose. The file properties are as follows: extension: .bmp size: 425,122 bytes width: 430 px height: 329 px horizontal res: 96 dpi vertical res: 96 dpi bit depth: 24 I recieve the following error: Allowed memory size of 18874368 bytes exhausted (tried to allocate 16973 bytes) To uncompress or load the image I use the following: private function open_image($file){ # Php.ini Fixes ini_set('memory_limit', '128M'); ini_set('gd.jpeg_ignore_warning', 1); # Find correct image type and return image object # JPEG: $image = imagecreatefromjpeg($file); if($image){return $image;} # GIF: $image = imagecreatefromgif($file); if($image){return $image;} # PNG: $image = imagecreatefrompng($file); if($image){return $image;} # GD File: $image = imagecreatefromgd($file); if($image){return $image;} # GD2 File: $im = imagecreatefromgd2($file); if($image){return $image;} # WBMP: $image = imagecreatefromwbmp($file); if($image){return $image;} # XBM: $image = imagecreatefromxbm($file); if($image){return $image;} # XPM: $image = imagecreatefromxpm($file); if($image){return $image;} # Try and load from string: $image = imagecreatefromstring(file_get_contents($file)); if($image){return $image;} return false; } I understand that in the php.ini file you have a memory limit for a particular function. Mine was set to 18M. I changed it to 128M in the php.ini file and the ini_set function in the code above. Now, I get an error: Out of memory (allocated 81264640) (tried to allocate 16973 bytes) I can't figure out why a 430kb image needs 81+Mb to resize and save. This makes no sense. Also, this only happens with .bmp files. Any GD gurus? Please help!! ??? Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 18, 2009 Author Share Posted April 18, 2009 I tried uploading another bitmap and ran into a different error. The page seems to hang and never returns an error, but no image upload... This is so f'n annoying. Nothing is worse than having the app work fine on your local machine and then it blow up online. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 18, 2009 Author Share Posted April 18, 2009 I downloaded a larger jpeg file. The properties are as follows... ext: .jpg size: 3.71 MB w: 3648 px h: 2736 h-res: 72 dpi v-res: 72 dpi bit-depth: 24 This image also won't upload correctly!!!!! WTF. Out of memory (allocated 80740352) (tried to allocate 65496 bytes) If this is a hosting issue, than I am done with PowWeb. Period. I have had so many issue with them screwing up my settings or speaking with techies that know absolutely nothing. Why is a 3.71 MB file using 80 megs for a simple resize? Plus the 400kb .bmp file?? This is insane. I currently have my max mem set to 300M......... Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 18, 2009 Author Share Posted April 18, 2009 no one? Quote Link to comment Share on other sites More sharing options...
Axeia Posted April 18, 2009 Share Posted April 18, 2009 No idea as to why it would require such an insane amount of memory, but if you got access to imagick you might want to give that a spin to see if it does a better job. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 18, 2009 Author Share Posted April 18, 2009 Me neither... I was wondering if there is a memory leak or something. I have done the calculations and a uncompressed version should not come near 50MB let alone 80+. I am speaking with my web host now and trying to find out how to install a php extension i.e. imagick. I have never installed an extension and the instructions look like chinese to me... Any simple informative guides not from php.net or pecl? Quote Link to comment Share on other sites More sharing options...
soak Posted April 18, 2009 Share Posted April 18, 2009 What OS and do you have ssh access or just cpanel? You'll also need the application imagemagick installed on the server Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 18, 2009 Author Share Posted April 18, 2009 I am using Powweb hosting. Its a Unix platform. Imagemagick is already installed. I only have access through cpanel. I think I just need to install imagick and i'll be ready to go... Quote Link to comment Share on other sites More sharing options...
soak Posted April 18, 2009 Share Posted April 18, 2009 Yep, all you need is the php extension. Have you checked to see if it's already there with phpinfo()? If it's not I'll have to pass, I don't use cpanel a lot. There should be plenty of guides out there though and I suspect it's faurly simple once you find the right area in cpanel. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 18, 2009 Author Share Posted April 18, 2009 yea... no its not installed. I downloaded the imagick-2.2.1 but I don't have a .dll file... I am wondering if I might need to compile this or something? I have never done anything like that before. The installation instructions I have found are definately not for noobs... Quote Link to comment Share on other sites More sharing options...
Axeia Posted April 18, 2009 Share Posted April 18, 2009 Sounds like you got problems setting it up locally? Under openSUSE it's complete easymode.. so if nothing else works you might want to install that (optionally under VMWare/VirtualBox). It's selecting the "LAMP" pattern during install (or later on under software management) and then simply clicking the one click installer on webpin edit: Oh right, I forgot to mention you'd need to restart apache afterwards do detect the changes but executing "rcapache2 restart" as root isn't too hard edit 2 Must have been reading too fast, and assumed things based on the .dll you posted. There is no .dll's on an unix platform. Quote Link to comment Share on other sites More sharing options...
soak Posted April 18, 2009 Share Posted April 18, 2009 Pretty sure you can do it from within cpanel somewhere. You shouldn't need to download anything AFAIK. Quote Link to comment 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.