cwebp to reduce site image sizes by 92% - in view of our being limited to 488mb each of photos.
back to thread https://www.caterhamlotus7.club/forums/topic/273938-new-website-feedback-and-ideas/?do=findComment&comment=2598222
about the images limit problem, I THINK Invision supports webp image format (edit it does see below) which uses much less space (92% less below) than jpeg and png i i u c cwebp AVAILABLE here: https://developers.google.com/speed/webp/docs/precompiled
for Windows Linuxes and Mac
so more about it here https://developers.google.com/speed/webp/
so I am wondering of t p t b could convert all our jpegs (see below) to webp and save (maybe) loads of space?
edit for example "WebP includes the lightweight encoding and decoding library libwebp
and the command line tools cwebp
and dwebp
for converting images to and from the WebP format"
WebP Converter Download
Convert your favorite collection from PNG and JPEG to WebP by downloading the precompiled cwebp
conversion tool for Linux, Windows or macOS.
I dread to consider whether it would break all links to images...
So I have done a conversion and here is the comparison for the image, one is jpeg 2.5MB (megabytes) and the webp version is 205k (kilobytes) : this is a 92% space saving.
The upper iimage is webp the lower is the jpeg, though I loaded the jpeg first.
Is there any difference? one is 92% smaller file size than the other.
I wonder if the site could do the conversion during image upload - if we approve of this tentative idea.
edit: a zoomed jpeg opens in a new tab a zoomed webp does not: unless "told" to open in new tab.
As regards club space resources:
Therefore, one terabyte reduced by 92% would be 81.92 gigabytes.
and
1 GB reduced by 92% would leave us with 0.08 GB, which is 80 MB
So I will be doing this as in my case it is a case of needs must or no more images for me.
The pros and cons are all about "lossyness" and webp is highly controllable in this.
This is a cli (command line interface) tool so not easy for the uninitiated. That's why I mention our site scripting it in. But I am very impressed at this point.
Apologies, this should now be a blog post. I will see if I can move it there - which is now this text
So a Mac terminal command to convert all jpegs and jpgs if not already converted, to webp files, with the following two warnings
1 - the cwebp command is given its complete absolute path to itself so I do not have to mess with editing path names and
2- the target directory/folder complete absolute path is also given. So if you have your path correct to your cwebp installation directory all you need do is edit the path to your folder containing your jpg and jpeg images.
In English: In my specified folder find jpegs and jpgs that have not yet been converted and convert them to webp format.
find "/Volumes/Data/Dropbox/! Cars/BDR Collection" -type f \( -name "*.jpeg" -o -name "*.jpg" \) -print0 | xargs -0 -I {} sh -c '[ ! -f "${1%.*}.webp" ] && /Applications/libwebp-1.3.2-mac-arm64/bin/cwebp "$1" -o "${1%.*}.webp"' _ {}
If we have terminal access to our site then to clarify, here's the breakdown:
- find "/Volumes/Data/Dropbox/! Cars/BDR Collection" starts the search in the specified directory.
- -type f restricts the search to files only.
- \( -name "*.jpeg" -o -name "*.jpg" \) is the expression that matches files ending in .jpeg or .jpg.
- -print0 outputs the full file path followed by a null character, ensuring that filenames with special characters (like spaces) are handled correctly.
- The pipe | sends the output of find to xargs.
- xargs -0 reads null-terminated strings, which is necessary because of the -print0 option used in find.
- sh -c '...' is the command executed for each file, where the existence of a .webp file with the same base name is checked before conversion.
This will include all nested subdirectories under the starting folder. If you ever need to limit the depth of the recursive search, find has a -maxdepth option that you can use to specify how deep in the directory tree to search.
HOWEVER, this changes the file extensions and a further site wide edit would have to fix that. Methinks hero required for that.
Edited by anthonym
3 Comments
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now