no me acuerdo creo que fixee el script

This commit is contained in:
simio 2025-06-12 08:26:30 -03:00
parent 203a251932
commit 06f862d7c7
2 changed files with 11 additions and 9 deletions

View File

@ -19,17 +19,16 @@ downscale_image() {
downscale_webp() { downscale_webp() {
local img="$1" local img="$1"
local width height local width height
dimensions=$(identify -format "%wx%h" "$img") dimensions=$(identify -format "%Wx%H-" "$img")
width=$(echo $dimensions | cut -d'x' -f1) width=$(echo $dimensions | cut -d'x' -f1)
height=$(echo $dimensions | cut -d'x' -f2) height=$(echo $dimensions | cut -d'x' -f2 | cut -d'-' -f1)
if [ "$width" -gt 960 ] || [ "$height" -gt 544 ]; then if [ "$width" -gt 960 ] || [ "$height" -gt 544 ]; then
gifname="${img}.gif" gifname="${img}.gif"
magick "$img" "$gifname" magick "$img" "$gifname"
gifsicle --resize _x544 --colors 256 "$gifname" > "${gifname}s" gifsicle --resize _x544 --colors 256 "$gifname" -o "${gifname}"
rm "$img" rm "$img"
rm "$gifname" rm "$gifname"
magick "${gifname}s" "$img" magick "${gifname}s" "$img"
rm "${gifname}s"
fi fi
} }
@ -149,14 +148,15 @@ find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname
# elif [[ "$img" == *".apng" ]]; then # elif [[ "$img" == *".apng" ]]; then
# downscale_apng "$img" # downscale_apng "$img"
elif [[ "$img" == *".gif" ]]; then elif [[ "$img" == *".gif" ]]; then
dimensions=$(identify -format "%wx%h" "$img") dimensions=$(identify -format "%Wx%H-" "$img")
width=$(echo $dimensions | cut -d'x' -f1) width=$(echo $dimensions | cut -d'x' -f1)
height=$(echo $dimensions | cut -d'x' -f2) height=$(echo $dimensions | cut -d'x' -f2 | cut -d'-' -f1)
if [ "$width" -gt 960 ] || [ "$height" -gt 544 ]; then if [ "$width" -gt 960 ] || [ "$height" -gt 544 ]; then
gifsicle --resize _x544 --colors 256 "$img" > "${img}s" gifsicle --resize _x544 --colors 256 "$img" -o "$img"
rm "$img" echo "Resized $img"
mv "${img}s" "$img"
fi fi
gifsicle -O3 "$img" -o "$img"
echo "Optimized $img"
else else
# Downscale image if necessary # Downscale image if necessary
downscale_image "$img" downscale_image "$img"

2
.zshrc
View File

@ -89,6 +89,8 @@ source $ZSH/oh-my-zsh.sh
# export MANPATH="/usr/local/man:$MANPATH" # export MANPATH="/usr/local/man:$MANPATH"
export PATH="$HOME/.local/share/gem/ruby/3.4.0/bin:$PATH"
# You may need to manually set your language environment # You may need to manually set your language environment
# export LANG=en_US.UTF-8 # export LANG=en_US.UTF-8