Forum Moderators: coopster

Message Too Old, No Replies

More Effective Image Zipping In PHP?

         

AdamAGB

11:59 pm on Jul 23, 2007 (gmt 0)

10+ Year Member



I searched the boards and couldn't find a previous answer to this...

I run an image-heavy website and the images are starting to take up a lot of space on our disk drives. I had thought about using GZIP to compress older, less accessed images and then uncompressing them on the fly, but the gains during my tests were negligible, reducing the filesize only a couple of percentage points

Am I on the wrong track to solving this problem?

ahmedtheking

9:31 am on Jul 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Correct me if I'm wrong, but there's always two issues here: disk space and processing power. If you were to compress all your images (compressing images isn't very effective at the best) and then uncompress them on the fly, this would use a lot of processing power. So say one day, a lot of people came and used the archived images, your server(s) would be shredded. That's not good.

Now you may be thinking that the best way then is to just get more space, and I think it may be. Space costs less than a faster processing machine.

This may not be what you want to hear, but when it comes to projects of my own, I'm ready to forfeit space for processing power.

Drag_Racer

10:37 am on Jul 24, 2007 (gmt 0)

10+ Year Member



more space, yes

but larger drives are not always the best option. If you just increase the disk size, you may create a bottle neck as a disk can only serve up so mauch data during a given time. I would archive older,and/or non-popular stuff to a differnet machine or run a server just to deliver images.

you could look into an image caching service as well. such as Akamai or Mirror Image if you got cash to cache..

PHP_Chimp

1:26 pm on Jul 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was trying to come up with a solution to the same problem, tried all sorts of zipping but the time taken to get the image to the user changed very little.

I believe that it is basically because unless you are storing your images in there raw format then they are already compressed. So compressing a jpg will get you very little saving in space. As converting an image to jpg or gif (or whatever other format you are using) has already placeed the image through its own compression algorithm.

So the answer that you probably dont want to hear is that they only way to get a real saving in image is to firstly make sure you are using the correct type of image i.e. photos = jpg, line art/text = gif, etc. If you need something more drastic then you may be able to save high quality jpg's at half size i.e. if you image is 100px square save a 50-75px square image and just use the html height and width to increase its size.