• Guest, The rules for the P & N subforum have been updated to prohibit "ad hominem" or personal attacks against other posters. See the full details in the post "Politics and News Rules & Guidelines."

Discussion Webp, so if I understand it correctly...

YuliApp

Senior member
Dec 27, 2017
273
71
71
desirehive.com
Webp is just replacement for png, not really usefull as a replacement for jpeg.

Tried to compare it with jpeg and all routines i tried failed to save simple jpeg (around 40Mpix) on lowest filesize setting.
Higher settings usually ended being larger than a jpeg 100% and saving time factor 10 or more longer :-/

Can't some genie finally develop lossless tiny AI powered photo file format to archive photos? For me it is more important than to fly to mars. Kthx.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
15,467
2,523
55
Webp can replace both JPEG and PNG. In theory, it's the best image compression method supported by all major browsers. It all depends on the settings you use.

Webp has three major modes, lossy, lossless, and near-lossless. I've rarely used anything but lossless either.

Here's a Bash script I use to convert PNGs to Webp's. The name is a reference to "PngOut", a a PNG optimizer. Note the arguments to cwebp: "cwebp -m 6 -q 100 -lossless"
Code:
#!/bin/bash
# Convert a bunch of images to lossless WebP.
# Usage: webpngout [-k] [path [path ...]]
# -k: Keep original files
delete=1
if [[ "$1" == "-k" ]] ; then
  delete=0
  shift
fi

PROCS=`grep processor /proc/cpuinfo | wc -l`
NAME='*.png'
find "$@" -type f -name "$NAME" -print0 | xargs -0 -n1 -I{} -P $PROCS sh -c 'cwebp -m 6 -q 100 -lossless -o "{}.webp" "{}" || rm -f "{}.webp"'

if [[ "$delete" == "1" ]] ; then
  #saved=0
  find "$@" -type f -name "$NAME" -print0 | 
    while IFS= read -r -d '' i; do
      if [[ -f "$i.webp" && ! -z "$i.webp" ]] ; then
        origsize=`stat -c%s "$i"`
        webpsize=`stat -c%s "$i.webp"`
        if (( $origsize > $webpsize )) ; then
          echo Webp is $(($origsize-$webpsize)) smaller, so deleting original $i
          #saved=$(($saved + $origsize - $webpsize))
          OLDDATE="`date -r "$i"`"
          touch -d "$OLDDATE" "$i.webp"
          rm "$i"
        else
          echo Webp is $(($webpsize-$origsize)) larger, so deleting webp $i.webp
          rm "$i.webp"
        fi
      fi
    done
  #echo $saved bytes saved
fi
If you're looking for good lossy compression, also look at AVIF. But it's not supported by all major browsers.

If you're looking to archive photos that are already JPEGs (i.e. you don't have a lossless source file), look at JPEG XL.
 
  • Like
  • Love
Reactions: mxnerd and YuliApp

YuliApp

Senior member
Dec 27, 2017
273
71
71
desirehive.com
Webp can replace both JPEG and PNG. In theory, it's the best image compression method supported by all major browsers. It all depends on the settings you use.

Webp has three major modes, lossy, lossless, and near-lossless. I've rarely used anything but lossless either.

Here's a Bash script I use to convert PNGs to Webp's. The name is a reference to "PngOut", a a PNG optimizer. Note the arguments to cwebp: "cwebp -m 6 -q 100 -lossless"
Code:
#!/bin/bash
# Convert a bunch of images to lossless WebP.
# Usage: webpngout [-k] [path [path ...]]
# -k: Keep original files
delete=1
if [[ "$1" == "-k" ]] ; then
  delete=0
  shift
fi

PROCS=`grep processor /proc/cpuinfo | wc -l`
NAME='*.png'
find "$@" -type f -name "$NAME" -print0 | xargs -0 -n1 -I{} -P $PROCS sh -c 'cwebp -m 6 -q 100 -lossless -o "{}.webp" "{}" || rm -f "{}.webp"'

if [[ "$delete" == "1" ]] ; then
  #saved=0
  find "$@" -type f -name "$NAME" -print0 |
    while IFS= read -r -d '' i; do
      if [[ -f "$i.webp" && ! -z "$i.webp" ]] ; then
        origsize=`stat -c%s "$i"`
        webpsize=`stat -c%s "$i.webp"`
        if (( $origsize > $webpsize )) ; then
          echo Webp is $(($origsize-$webpsize)) smaller, so deleting original $i
          #saved=$(($saved + $origsize - $webpsize))
          OLDDATE="`date -r "$i"`"
          touch -d "$OLDDATE" "$i.webp"
          rm "$i"
        else
          echo Webp is $(($webpsize-$origsize)) larger, so deleting webp $i.webp
          rm "$i.webp"
        fi
      fi
    done
  #echo $saved bytes saved
fi
If you're looking for good lossy compression, also look at AVIF. But it's not supported by all major browsers.

If you're looking to archive photos that are already JPEGs (i.e. you don't have a lossless source file), look at JPEG XL.
thank you this was very valuable answer. I am looking primarily to recompress existing jpegs (prefferably that they would not lose quality on that) and from archive PSDs. I can't dream that something could replace jpegs in mainstream (they are so fast! and i need to scroll in realtime) but for archive i could save few xxx euros in the cloud by having smaller size
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
15,467
2,523
55
I think you and I have different definitions of "archive". For now, JPEG XL is good for archiving JPEGs...in a vault somewhere. Because no browser officially supports it yet, it's no good for serving files to users, unless you can throw a server-side decoder in front of them, which trades space for processing power.

Recoding from lossless sources like Photoshop should probably use either a WebP lossy encoding or MozJPEG these days. (I use Guetzli from Google, but I'm a rebel. :p) It's up to you to select acceptable quality settings. You might be able to find a plugin, or ImageOptim is free for Mac.

Existing JPEGs might benefit from "JPEGrescan". The original is written in Perl. I contributed a little. Supposedly MozJPEG does the same thing. Again, you might be able to find a plugin or ImageOptim.
 
  • Like
Reactions: YuliApp and mxnerd

YuliApp

Senior member
Dec 27, 2017
273
71
71
desirehive.com
I think you and I have different definitions of "archive". For now, JPEG XL is good for archiving JPEGs...in a vault somewhere. Because no browser officially supports it yet, it's no good for serving files to users, unless you can throw a server-side decoder in front of them, which trades space for processing power.

Recoding from lossless sources like Photoshop should probably use either a WebP lossy encoding or MozJPEG these days. (I use Guetzli from Google, but I'm a rebel. :p) It's up to you to select acceptable quality settings. You might be able to find a plugin, or ImageOptim is free for Mac.

Existing JPEGs might benefit from "JPEGrescan". The original is written in Perl. I contributed a little. Supposedly MozJPEG does the same thing. Again, you might be able to find a plugin or ImageOptim.
I think we have same definition, the archive is just write once read (hopefully) never memory. Files there do not need to be accessed by front end. I mean i could in theory write some code to reactivate and download and convert them, but ain't nobody got time for that. Only time i would need it is if all physical backups die.

Thank you for the response i will reevaluate your suggestion. Yes basically i have tons of 100% jpegs which i would like to make smaller (20+% to make my time worth) with lossless process. And few more tons of lossless PSDs which i need to reduce with as good (lossy) compression as possible withough affecting quality much (ok i use sRGB and 8bit instead of PROPhoto and 16bit, so it is already tons of data lost, but i keep in PSDs only what might go to print one day).

I pay for size so 20% is ~20€ per month "forever" already. PSDs are already about 18times larger so this is real money maker in any way.
 

Cogman

Lifer
Sep 19, 2000
10,271
114
106
I think we have same definition, the archive is just write once read (hopefully) never memory. Files there do not need to be accessed by front end. I mean i could in theory write some code to reactivate and download and convert them, but ain't nobody got time for that. Only time i would need it is if all physical backups die.

Thank you for the response i will reevaluate your suggestion. Yes basically i have tons of 100% jpegs which i would like to make smaller (20+% to make my time worth) with lossless process. And few more tons of lossless PSDs which i need to reduce with as good (lossy) compression as possible withough affecting quality much (ok i use sRGB and 8bit instead of PROPhoto and 16bit, so it is already tons of data lost, but i keep in PSDs only what might go to print one day).

I pay for size so 20% is ~20€ per month "forever" already. PSDs are already about 18times larger so this is real money maker in any way.
If you aren't sending them to the browser, then AVIF and Jpeg-XL are your best options. I personally prefer AVIF.
 

ASK THE COMMUNITY

TRENDING THREADS