Want more timely Centmin Mod News Updates?
Become a Member

optimise-images.sh missing "badly optimized" webp removal script?

Discussion in 'Web Development & Web Performance' started by Benjamin74, Jun 23, 2019.

Tags:
  1. Benjamin74

    Benjamin74 Premium Member Premium Member

    46
    4
    8
    May 2, 2016
    Ratings:
    +10
    Local Time:
    11:10 PM
    Hello and thanks again for this awesome tool that is CMM!

    Quick question :

    As you probably know, a very-well optimized png (in my case : logos, which went through png64 and ImageOptim.app on osx), will be converted into a BIGGER webp file.

    Thus, I'm wondering if optimise-images.sh shouldn't have a "cleanup" routine which would:

    - go through all the png/jpg "original" images
    - compare these with their "webp" versions
    - delete the webp version if the webp version is bigger than the original

    Later on, the nginx vhost configuration would revert back to serving the original "better than webp" file format since the webp has been deleted.

    What do you think?

    Or maybe it's already there and I didn't see it lol, optimise-images.sh is very powerful so maybe I missed a step somewhere.

    I'll see if I can find someone to create this bash script and share it with you if it's really missing.

    Cheers,
     
  2. eva2000

    eva2000 Administrator Staff Member

    41,754
    9,400
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,445
    Local Time:
    7:10 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    nginx wouldn't be able to do that it's simple if .png exists and .webp exists, server .webp to browsers that support it.

    and optimise-images.sh script doesn't have such function - you can see and inspect the code at centminmod/optimise-images though i suppose it would be easy to compare png vs webp versions and decide if webp version is bigger than png version
     
  3. eva2000

    eva2000 Administrator Staff Member

    41,754
    9,400
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,445
    Local Time:
    7:10 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    do you have an example png64 png image i can add to optimise-images.sh benchmark test mode so can test it on a proposed updated optimise-images.sh with webp image size check
     
  4. Benjamin74

    Benjamin74 Premium Member Premium Member

    46
    4
    8
    May 2, 2016
    Ratings:
    +10
    Local Time:
    11:10 PM
    I know if png AND webp are there, nginx will serve the webp to webp enabled browsers, thus the need to delete the "bigger" webp if it's bigger than the PNG. That's what I meant as "revert back" (basically it's what the try_files $uri$webp_extension $uri =404; is doing).

    I'll generate a few example PNGs for you.
     
  5. Benjamin74

    Benjamin74 Premium Member Premium Member

    46
    4
    8
    May 2, 2016
    Ratings:
    +10
    Local Time:
    11:10 PM
    OK so obviously when I try to recreate the scenario, I don't get a high enough size difference so I'll PM you my real-world images.
     
    • Like Like x 1