lundi 7 octobre 2019

Laravel 5: Why loaded images file size are bigger than actual size on disk?

I've been trying to optimize images on a Laravel 5 project.

I've used TinyPNG to compress images in the project. After compressing the images, the file size drop something like from 195kb to 67kb.

However, when doing performance testing, I found that time images are still the problem.

I found that the images still have the original file size (195kb) when loading on the website, according the Chrome Developer Tool.

I wonder why the images file size is smaller on disk, but bigger on browser load.

Note: I run php artisan clear:cache, view:clear, and config:clear. Also, disabled server cache and CDN.

My code is listed bellow

    $images = glob("" . $directory . "*.png");
    foreach ( $images as $image ){
        $optimized = Tinify::fromFile($image);
        $optimized->toFile($image);
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire