使用 Gifsicle 调整目录中所有文件的大小

Resizing all files in a directory using Gifsicle

我正在尝试调整 MacOsGifsicle 目录中所有文件的大小。我能够调整单个文件的大小。但是如何调整目录中所有文件的大小?

gifsicle original.gif --resize 600x600 > _resized.gif

这将在 BASH 好友中起作用。

#!/bin/bash
my_path=/var/www/mywebpage/images
all_files=$( find $my_path -type f -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' -o -name '*.gif' )
cd $my_path;
while read line
do
    echo "About to convert $line ..."
    gifsicle $line --resize 600x600 > ./tmp_image && cat ./tmp_image > $line
    echo "Done!"
done <<< "$all_files"

此致!

这应该有效

for g in *.gif; do
    d=${g%.gif}; gifsicle --resize 600x600 < "$g" > "$d-resized.gif";
done