php - optimize image file size

531 views Asked by At

I'm making a web application for online comic. My biggest difficulty things are how to save the disk space when store the images (i don't have money ^^). I try to use GD2 to resize the image, convert to jpg, reduce the qualities...but the file size of each image still around 100kb.

For example: MY IMAGE with 650x900 px with some character, text.., no color, just black & white, the file size is 100kb. But, when i making a NEW BLANK file with the same dimensions in photoshop and fill it all black (i think black color will make the file size more higher), then save on jpg, this new file size just only 8kb.

The question is, why the file size of MY IMAGE (with less black pixel) is higher than the NEW BLANK image with more black pixel? Is there anything inside the image source? And any solution to reduce the file size?

Thank all.

2

There are 2 answers

1
Thomas Martin Klein On

Basically question one is what format are you using. I suggest you use PNG for black and white images. If it is possible use 1bit PNG. Image compression i a complex thing. But no not the black pixels make the file size, but the variation of the pixels. But it is really a complex question.

see: http://en.wikipedia.org/wiki/Image_compression and http://en.wikipedia.org/wiki/Portable_Network_Graphics for some info on the subject.

For the best results if your images are currently JPEG-s then you need to apply somekind of noise reduction. For truly black-and-white (not grayscale) bumping up the contrast might help with that. Also strip out all meta information from the image.

0
Benjamin Hollon On

One helpful tool to lower file size of images without reducing the quality is TinyPNG. This can cut the file size by up to about 80% without making any noticeable changes to the image itself. It has helped me to cut down my file sizes by an average of about 70%, and I hope it can help you too!