jaydipsavaliya / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

JPG Optimisation #434

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
With the binary jpegoptim installed - https://github.com/glennr/jpegoptim we 
can optimise JPGs like we can with pngcrush/optipng.

if (!defined('JPEGOPTIM_ENABLED')) define ('JPEGOPTIM_ENABLED', true);
if (!defined('JPEGOPTIM_PATH')) define ('JPEGOPTIM_PATH', 
'/usr/local/bin/jpegoptim'); 

else if ($imgType == 'jpg' && JPEGOPTIM_ENABLED && JPEGOPTIM_PATH && 
@is_file(JPEGOPTIM_PATH)) {
            $exec = JPEGOPTIM_PATH;
            $this->debug(3, "jpegoptim'ing $tempfile");
            $presize = filesize($tempfile);
            $out = `$exec --strip-all $tempfile`; //you can use up to -o7 but it really slows things down
            clearstatcache();
            $aftersize = filesize($tempfile);
            $sizeDrop = $presize - $aftersize;
            if ($sizeDrop > 0) {
                $this->debug(1, "jpegoptim reduced size by $sizeDrop");
            } else if ($sizeDrop < 0) {
                $this->debug(1, "jpegoptim increased size! Difference was: $sizeDrop");
            } else {
                $this->debug(1, "jpegoptim did not change image size.");
            }
        }

Original issue reported on code.google.com by kb6...@gmail.com on 22 Feb 2013 at 5:43

GoogleCodeExporter commented 8 years ago
Hi,

I know its been a while since you posted this.

Is this snippet known to be working? If so is there any chance of posting a 
TimThumb.PHP with it in place. 

We are having trouble getting it to fire on our script.

Thanks!

Original comment by michael....@gmail.com on 18 Mar 2014 at 6:59