Jump to content

Mystery: Shrinking PHP Filesize


ExpertAlmost

Recommended Posts

Good morning Experts!

 

My code creates a PNG file output 505 x 600 pixels, 24bit, 96dpi. The average file size is 130kb. No mystery there.

 

Here is the mystery: when I open the file using ACDSee (v10) and then "save as" (even with the same filename), the file size SHRINKS to about 80kb. All the specs remain the same and I can see no difference in the image!  How in the world... What could an ACDSee file-save-as be doing and how do I do it in PHP? Doing a file-save-as in Windows Paint has the same result!

 

So I have tried to reduce the filesize in the code using compression and filters: from imagepng($Image, $ImageName) to imagepng($Image, $ImageName, 9, PNG_ALL_FILTERS). No difference. I tried running through PNGCRUSH, file size only goes to 112kb. The mystery is driving me crazy.

 

Any ideas of what to check in my code or image? Any ideas of tricks to try in the code? A 30% filesize reduction is too great to ignore.

 

I've attached a not-yet-shrunk file for your entertainment  (It appears that the upload program wont allow my original as it is 120kb)

 

Thank you in advance for all your ideas!

 

Link to comment
https://forums.phpfreaks.com/topic/260238-mystery-shrinking-php-filesize/
Share on other sites

Just to close out the thread...

 

My original file was interlaced! Makes for a quicker load but a larger file. I saved my base image as NOT interlaced and threw in a imageinterlace($BscImg, 0); to make sure that anything else I did was not interlaced. Reduced file size from 124KB to 79KB. No other changes in palette or sizes.

 

Best of luck to all of you!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.