Is it possible to convert png to avif inside DT?

Går du ind i det første kammer, da ser du midt på gulvet en stor kiste, oven på den sidder en hund; han har et par øjne så store som et par tekopper, men det skal du ikke bryde dig om! Jeg giver dig mit blåternede forklæde, det kan du brede ud på gulvet; gå så rask hen og tag hunden, sæt ham på mit forklæde, luk kisten op og tag lige så mange skillinger, du vil.

I haven’t seen that stamp before, but I immediately recognized the scene!

And I’m glad the script helps :smiley: Saving 10GB is a lot.

A couple of comments. The documentation says:

cwebp [options] input_file -o output_file.webp

I put the variable ‌cwebpArgs at the beginning to make it easy to adjust the conversion settings. Just change that.
(Maybe I wasn’t explicit enough and calling it cwebpOptions or adding a comment would be clearer).

set cwebpArgs to " -q 90 -m 6 -metadata icc "

Instead of adding it like this:

do shell script (cwebpPath & cwebpArgs & quoted form of thePath & " -metadata icc -o " & quoted form of newImgPath)

Also, -q 90 might be a bit high depending on what you want (the default is 75), though adding -m 6 helps a bit. It was just a placeholder configuration.

You could try the different presets. ‌-near_lossless can also be worth trying for tricky images. There’s also a -resize option.

Ha ha, I missed that troej. I’m getting sleepy. I will use the variable and try a few options - I think you’re right, 75 or 80 might work as well, given that the images are usually more like line-drawings. And I will try -near_lossless. The -resize option will definitely come handy.

It is interesting that Adobe Lightroom chose to add an option to AVIF, but not webp - WHILE Adobe Photoshop can use webp (via a Google plugin) and not AVIF.

Hm, there is a brew AVIF encoder:

Cool, just downloaded to try it out. Adjusting the script to use avifenc should be easy enough. It uses the format

avifenc [options] input.[jpg|jpeg|png|y4m] output.avif

– so something like:

set avifenc_Path to "/opt/homebrew/bin/avifenc"
set avifenc_Args to " -q 80 " -- Adjust options to your liking

...
	
set theRecords to selected records whose (type is picture) and (filename does not end with ".avif")
	
...
	
do shell script (avifenc_Path & avifenc_Args & quoted form of thePath & space & quoted form of newImgPath)