Error: Could not fetch http://thedevnet.com/wp-content/plugins/gd-star-rating/css/gdsr.css.php?t=0&s=a10i10m20k20c05r05%23121620243046%23121620243240%23s1pchristmas%23s1pcrystal%23s1pdarkness%23s1poxygen%23s1goxygen_gif%23s1pplain%23s1ppumpkin%23s1psoft%23s1pstarrating%23s1pstarscape%23t1pclassical%23t1pstarrating%23t1gstarrating_gif&ver=1.7.2 for caching. You might need to exclude this file in WP Minify options. The Developer Network – Image Size Limiter

Image Size Limiter

While programming, sometimes we run into image sizing limitations.
It can be pretty hard to work around. Then we stumbled upon this class.
You can compress any image supported by GD to a specific file size, and have it reduce to the size needed.
This class also maximizes the resolution of the pic to the given size. This will minimize your image loss.
The image will be converted to .jpg.

Resize Demonstration:

  1. <?
  2. http://thedevnet.com/php/classes/image-size-limiter/
  3. // Load class file
  4. require_once('class-jpegfit.php');
  5. // Create jpegfit object
  6. $obj=new JpegFit();
  7.  
  8. // Set filename of image – you MUST change this!
  9. $obj->setImageFilePath('input.png');
  10.  
  11. // Set target size in bytes
  12. $obj->setTargetSize(10240);
  13.  
  14. // Set target resolution
  15. $obj->setResolution(256,256);
  16.  
  17. // Run function
  18. $obj->fit();
  19.  
  20. // Save image with filename
  21. $obj->saveImage('out.jpg');
  22.  
  23. // OPTIONAL printing of debug
  24. $obj->dprint();
  25. ?>
Jpeg Image Resizer
jpegfit-2007-09-13.zip
Version: 1.0

124.4 KiB
9 Downloads
Details…

GD Star Rating
loading...

Originally posted 2009-10-21 15:56:58.

Popularity: 7%

Posted by natster   @   27 August 2010
Tags : , ,

Related Posts

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

1 Comments

Comments
Oct 21, 2009
4:41 pm
#1 irbobo :

might be a good idea for an image hosting service script

GD Star Rating
loading...
Leave a Comment

You must be logged in to post a comment.

Previous Post
« PHP Charts
Next Post
PHP User Management Script Using htaccess »
Powered by Wordpress   |   Lunated designed by ZenVerse