Skip to content

Instantly share code, notes, and snippets.

@Blake-C
Created March 12, 2020 03:30
Show Gist options
  • Save Blake-C/0bce695e08a236df33f0e87110b8af6b to your computer and use it in GitHub Desktop.
Save Blake-C/0bce695e08a236df33f0e87110b8af6b to your computer and use it in GitHub Desktop.
Optimizing Images with mogrify & convert
find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | rename --make-dirs --lower-case --keep-extension --expr 's/[^[:alnum:]\/]+/-/g; s/\A-*//; s/[\^-]*$//' --hardlink --trim --prepend='./optimized/'
find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | magick '*.jpg[1000x1000]'
convert *.png -set filename:base "%[basename]" "%[filename:base].jpg"
convert '*.*[700x700]' %03d-opt.jpg
convert '*.*[700x700]' -verbose -quality 80 -set filename:base "%[basename]" "%[filename:base].jpg"
find . -iname '*.jpg' -exec convert \{} -verbose -set filename:base "%[base]" -resize 1920x1080\> "/folder/images/%[filename:base].JPG" \;
find . -iname '*.jpg' -exec convert -verbose -quality 80 -resize 1600\> "{}" "FOO_FOLDER/{}" \;
# find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | convert "@-[700x700]" verbose -quality 80 -resize 800x800 -set filename:base "%[basename]" "%[filename:base].jpg"
# find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | convert @- -verbose -strip -quality 70 -resize 'x900'\> -set filename:base "%[basename]" "%[filename:base].jpg"
# find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | convert @- -verbose -strip -quality 70 -resize 'x900'\> -set filename:base "%[basename]" "%[filename:base].jpg"
find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | mogrify -verbose -strip -quality 70 -resize 'x900'\> @-
find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | mogrify -strip -quality 70 -resize 'x900'\> @-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment