#!/bin/bash #!/bin/bash width=$1 if [ -z "$width" ] then width=1920 fi directory=resize-$width mkdir $directory # prevent empty directories from returning *.jpg in for loop shopt -s nullglob for ext in jpg jpeg png; do for file in *."$ext"; do echo resizing "$file"; mogrify -path $directory -filter Triangle -define filter:support=2 -thumbnail $width -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip "$file" done done