Created
May 3, 2016 17:09
-
-
Save drakemccabe/2ca9f51a9a39b9d2c4ac3c8efd5da3c0 to your computer and use it in GitHub Desktop.
Find all files under a certain size or dimension and then resize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find files over 300kb and resize to 300kb | |
identify -format '%b %h %i\n' ./*.png | | |
awk '$1 > 300000 {sub(/^[^ ]* [^ ]* /, ""); print}' | | |
tr '\n' '\0' | | |
xargs -0 mogrify -define png:extent=300KB | |
# Find files over 600px width and resize to 600px while keeping ratio | |
identify -format '%w %h %i\n' ./*.png | | |
awk '$1 > 600 {sub(/^[^ ]* [^ ]* /, ""); print}' | | |
tr '\n' '\0' | | |
xargs -0 mogrify -resize '600' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment