PHP Classes
elePHPant
Icontem

JPEG Fit: Optimize images to fit in a given file size limit

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2007-09-13 (9 years ago) RSS 2.0 feedNot enough user ratingsTotal: 1,224 All time: 3,031 This week: 738Up
Version License PHP version Categories
jpegfit 1.0.0Freeware5.0.0PHP 5, Graphics
Description Author

This class can be used to optimize images to fit within a given file size limit.

It takes a picture in any format supported by the GD library and generates a JPEG picture with the maximum quality factor that makes the picture file size not exceed a given limit.

This class is similar to the JPEG Reducer class. It uses the binary search algorithm to reach the ideal quality factor in the smallest number of iterations.

The class stops searching when a given number of limit iterations is reached or when the quality factor difference between the ideal and the found values is less than the configured precision value.

Name: Zafar Iqbal <contact>
Classes: 8 packages by
Country: Greece Greece
Innovation award
Innovation award
Nominee: 2x

Details
JpegFit

A PHP class that tries to encode an input image to the jpeg file format with a given file size.

It is similar to the JPEG Reducer Class (http://www.phpclasses.org/jpegreducer) but more advanced.

This class uses a binary search algorithm to rapidly locate the jpeg quality setting which is close to the target file size.

Also, the input image can be of JPEG, PNG, GIF, WBMP, and GD2 formats.

If target file size is lower than the minimum possible then lowest quality is used.

If target file size is greater than the maximum possible then the highest quality is used.

If target file size is inbetween then the closest file size will be found, making sure it does not exceed target file size.

2007-04-12	Added Image Resource getters and setters with examples
2007-03-29	First version

Zafar Iqbal <ultrasine@gmail.com>
Screenshots  
  • 61081-bytes.jpg
  Files folder image Files  
File Role Description
Accessible without login Image file 61081.jpg Output First ever jpeg image to show file size in image?
Plain text file class-jpegfit.php Class JpegFit Class
Plain text file example1.php Example Example 1
Plain text file example2.php Example Example 2
Plain text file example3.php Example Example 3
Plain text file example4.php Example Example 4
Plain text file example5.php Example Example to demo resize
Plain text file README Data README

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,224
This week:0
All time:3,031
This week:738Up