Compressing Images

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

Compressing Images

Post 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!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Compressing Images

Post 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).
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

Re: Compressing Images

Post by paqman »

I had a feeling that might be the answer... Thanks though!
Post Reply