Closed Disonantemus closed 1 year ago
Confirmed.
However, it's hard to tell how this is supposed to work because imlib2's "quality" thing is entirely undocumented (as far as I can see). So I'm not even sure what that manpage description is based on.
Looks like it got introduced at https://github.com/resurrecting-open-source-projects/scrot/commit/fc27d9f7301df1c7577be9080da7fc14e9c5836e. Before that commit it used to say:
-q, --quality NUM Image quality (1-100) high value means high size, low
compression. Default: 75. (Effect differs depending on
file format chosen).
Which was correct for PNG files, but probably not correct for other files.
Note to self: open an issue at imlib2 asking for documentation/clarification on how the "quality" value is supposed to work.
Also, using '--format webp' it's better than
png
to get smaller lossless screenshots, only--quality 100
appears lossless to me (webp has lossless and lossy compression) you can test with 'cwebp' (libwebp), and ti would be better to have that quality control, maybe a--lossless
option; with same file tested before:cwebp in.png -o out.webp -z 9
There's plan to add a separate --compression flag, see #290. So once that's implemented, you should be able to do something like scrot --format webp --quality 100 --compression 9
to get highly compressed lossless webp (or jxl with new imlib2 version).
But until that's implemented, you can use the following, which will run the cwebp command on the new screenshot:
$ scrot -e 'cwebp $f -o $f -z 9 -lossless'
-e 'cwebp $f -o $f -z 9 -lossless'
If I do that ...\
I get webp
file but with .png
extention:
> scrot -e 'cwebp $f -o $f -z 9 -lossless'
2023-05-08-094948_1920x1080_scrot.png
If I try to "force" an extention, I get 2 files, $n
didn't work, just output same as $f
, maybe it's expected, but I did try, like this:
> scrot -e 'cwebp $f -o $n.webp -z 9 -lossless'
2023-05-08-094948_1920x1080_scrot.png
2023-05-08-094948_1920x1080_scrot.png.webp
Same as before, but I can remove old one:
> scrot -e 'cwebp $f -o $n.webp -z 9 -lossless; rm $f'
2023-05-08-094948_1920x1080_scrot.png.webp
Now, how can I get a file with no '.png' in the name? I did try with '${f%.*}' (some shell expansion with no success).
Now, how can I get a file with no '.png' in the name? I did try with '${f%.*}' (some shell expansion with no success).
You can give scrot a filename: scrot -e 'cwebp $f -o $f -z 9 -lossless' shot.webp
.
See the "SPECIAL STRINGS" section of the manpage also if you want the filename to have date/time etc.
Thanks! that worked!
I did read that part, because I did use "$n" (basename), but didn't work as a parameter for cwebp, but with your example I can customize it to my liking.
man scrot.1
It's inverse of that for lossless, saving a lossless format like default
png
:Also, using '--format webp' it's better than
png
to get smaller lossless screenshots, only--quality 100
appears lossless to me (webp has lossless and lossy compression) you can test with 'cwebp' (libwebp), and ti would be better to have that quality control, maybe a '--losslessoption; with same file tested before:
cwebp in.png -o out.webp -z 9`