# mogrify -resize 3840x2160 *.jpg # jpeg to jpg find . -type f -iregex ".*\.jpe?g" -exec mogrify -format jpg {} \; # resize everything to max 4k # TODO: also scales up... but shouldn't! find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g|gif|webp)" -exec mogrify -resize 3840x2160 {} \; find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g|gif|webp)" -exec mogrify -resize 1920x1080 {} \; find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g|gif|webp)" -exec mogrify -resize 1200x675 {} \; # optimize jpg find . -type f -iregex ".*\.jpe?g" -exec jpegoptim --strip-all {} \; find . -type f -iname "*.jpg" -exec jpegoptim --strip-all {} \; # optimize png find . -type f -iname "*.png" -exec optipng -o5 {} \; # convert to webp find . -type f -regextype posix-extended -iregex ".*\.(png|jpe?g)" -exec convert {} -quality 90 -define webp:lossless=true $(echo {} | cut -d . -f 1).webp \; # add border to image convert $img.png -background none -bordercolor none -border 20 $img.png # square image for favicon # order of things is important convert $img -background none -thumbnail 64x64^ -gravity center -extent ${longestside}x${x} $img # crop image to size - from center # https://www.imagemagick.org/discourse-server/viewtopic.php?t=13793 convert $img -resize 1200x900^ -gravity center -crop 1200x900+0+0 $img # svg to png convert -scale ${x}x${y} -extent 110%x110% -gravity center -background transparent $svg $png # https://stackoverflow.com/a/12690135 convert -density 1200 -resize 200x -background none $svg $png