note 101612 deleted from function.imagepng by danbrown

From: Date: Thu, 30 Dec 2010 16:06:55 +0000
Subject: note 101612 deleted from function.imagepng by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175335@lists.php.net to get a copy of this message
Note Submitter: smalltux at yahoo dot com ---- I have a huge collection of movies and a catalogue maintained in PHP/MySQL. I have a poster (jpg/giff/png file) for each movie. I got an idea to create a mosaic poster of all Top#250 IMDB movies consisting of scaled down versions of individual posters. In order to print the poster afterwards, I hade to make it big (and when I say 'big' I mean REALLY, REALLY BIG), in order to keep individual posters readble. PHP was more than fit for the purpose and easily handled my poster dimension (5500x3200px!). But... everything worked well untill the final statement which saves the final image to the disk: imagepng($monster_poster_resource, $poster_file); At that point, I got "out of memory" error which could not be rectified because my (shared) hosting provider did not want to increase the amount of memory available to me (128MB). On my local machine with 256MB of RAM for PHP, I got a PNG image of 30MB+ without a glitch. Then I switched to JPEG and replaced imagepng() with: imagejpeg($monster_poster_resource, $poster_file, 100); Yes, it *worked*, even with default settings of my hosting provider. I got a smaller image file (17MB) without any loss of quality. So if you insist on PNG think twice: if you don't need alpha channel, JPEG format is just fine: creation of JPEG files seems to be more efficient in terms of memory and disk space consumption. If you want to see the final result (100% pure PHP), here it is: http://www.luka.in.rs/poster.php If you want the source code, just drop me an email.

« previous php.notes (#175335) next »