Page 1 of 1

Compressing Images

Posted: Tue Jun 09, 2009 2:51 am
by paqman
So, after years of not understanding exactly why my image resizing script for uploaded images was crashing, I finally get it (after reading through a forum which gave the few extra hints I was missing). I thought it was a problem caused by the size of the photo, in bytes, being uploaded, but now realize that when PHP loads an image as a variable it loads it like a bitmap, so 2048x2048x24 bits = 12.6 MB of variable memory alone (if that is wrong at any point, please tell me!).

After finally getting that, I still haven't solved my problem. Does anyone know of a way to keep an image compressed in any way (like how a JPEG compresses the image) for resizing, or of any stand alone scripts that will resize larger images through php? Any insight would be greatly appreciated!

Re: Compressing Images

Posted: Tue Jun 09, 2009 3:23 am
by VladSun
PHP has to have the image as a bitmap prior any processing of its data.
Simply, you can't (or it's too difficult to) process the image in the compressed domain (i.e. JPEG, GIF, etc. binary file), you have to process it in the spatial domain (i.e. bitmap).

Re: Compressing Images

Posted: Tue Jun 09, 2009 3:57 am
by paqman
I had a feeling that might be the answer... Thanks though!