1

I am trying to resize all files in a directory with Gifsicle in MacOs. I am able to resize single file. But how to resize all files in a directory?

gifsicle original.gif --resize 600x600 > _resized.gif
birdcage
  • 2,638
  • 4
  • 35
  • 58

2 Answers2

1

This will work in BASH buddy.

#!/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"

Regards!

Matias Barrios
  • 4,674
  • 3
  • 22
  • 49
1

This should work

for g in *.gif; do
    d=${g%.gif}; gifsicle --resize 600x600 < "$g" > "$d-resized.gif";
done
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134