Monday, March 14, 2022

Convert webp to png

 

Any file to PNG

$ sudo apt install webp
$ for i in *.webp; do name=`echo "$i" | cut -d'.' -f1`; echo "$name"; dwebp "$i"
-o "${name}.png"; done

Add to Nautilus Script
fincahuanaco@pisces:~/.local/share/nautilus/scripts$ cat toPNG   
dwebp $1 -o "$1.png"
rm $1

$chmod +x toPNG 
 
Updated to Selection to PNG (2023)
#!/bin/bash
count=0
success=0

# Transform command line arguments (if provided)
[[ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]] &&
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS=$(printf "%s\n" "$@")

# Process each file in turn
while IFS= read -r src
do
if [[ -f "$src" ]]
then
# Target
dst="${src}.png"

# Primary conversion to PNG
step=0

dwebp $src -o $dst && ((step++))

# Remove src
if [[ step -eq 1 ]]
then
rm $src && ((step++))
fi

# Update
if [[ step -eq 2 ]]
then
((success++))
fi

# Count it
((count++))
fi

done <<<"$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"

[[ count -gt 1 ]] &&
notify-send "Conversion finished ($success files of $count)"

exit $((count - success)) 
 
AVIF format support
[1] libavif https://github.com/AOMediaCodec/libavif/ 
 
References:

[1] https://unix.stackexchange.com/questions/710013/making-a-bash-script-apply-to-only-selected-files-nautilus 








No comments:

PostgreSQL json fields

select name->'es_PE',* from product_template where name->>'es_PE' like '%MEGACI%'   References: [1] https:/...