Skip to content

Instantly share code, notes, and snippets.

@tylerlittlefield
Last active December 7, 2018 20:44
Show Gist options
  • Save tylerlittlefield/1b4bdd1cfbf486af1aa2240d8ce2f829 to your computer and use it in GitHub Desktop.
Save tylerlittlefield/1b4bdd1cfbf486af1aa2240d8ce2f829 to your computer and use it in GitHub Desktop.
Recursively resize photos

Make sure to cd into the directory with subfolders containing photos, for example:

#> λ ~/ cd Desktop/test
#> λ ~/Desktop/test/ ls
#> 100003 100004

Where 100003 and 100004 are folders that contain photos. If the folders don't exist and you need to rename photos based on the file name, see this unix solution or this windows solution.

Next, run the following command to explicitly limit the image to being, at most, 240x240 pixels:

find . -name '*.jpg' -execdir mogrify -resize "240x240>" {} \;

That's it! This converts a 3036 × 4048 image to 180 × 240 and a 4048 × 3036 to 240 × 180.

Sources:

  1. Limit image size
  2. Rename images in windows
  3. Rename images in unix... cant remember :/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment