Images compression

edited July 2015 in Installation
Hi!
My site has a lot of large images and to improve site performance I compress them manually, I use on_after_post hook that takes path to the image and with help of the native php function does what I need:
ImageJPEG (ImageCreateFromString(file_get_contents($img)), $img, $quality);
But this method not fits anymore, give me an advice how to make compression automatic for all downloadable images?

Comments

  • edited 2:21AM
    There currently is not an easy way to hook into FUEL that way without making change to a core file. The file you'd want to change is the fuel/modules/fuel/libraries/Fuel_assets.php file in particular the "upload" method.
  • edited 2:21AM
    Thanks for the tip!
    I'll try to figure out.
  • edited 2:21AM
    Hi!
    in file fuel/modules/fuel/libraries/Fuel_assets.php on line 390 (before return TRUE) added a condition:
    // IF is JPEG if (exif_imagetype($file['full_path']) == IMAGETYPE_JPEG) { ImageJPEG(ImageCreateFromString(file_get_contents($file['full_path'])), $file['full_path'], 85); }
    Now all JPEG's compressed and have less weight.
    Thanks for the help!
Sign In or Register to comment.