Last active
October 12, 2017 17:30
-
-
Save paazmaya/d0d874df3c8aa9bf41e6a69c43e6984c to your computer and use it in GitHub Desktop.
Find image files and optimise them with different command line tools
This file contains hidden or 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
#!/bin/bash | |
# Find all JPEG files and do stuff with https://github.com/google/guetzli | |
find . -maxdepth 4 -type f -iname '*.jpg' \ | |
-exec sh -c '(guetzli "{}" "{}.jpg")' ';' | |
This file contains hidden or 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
#!/bin/bash | |
# Find all JPEG files and do stuff with http://jpegclub.org/jpegtran/ | |
find . -maxdepth 4 -type f -iname '*.jpg' \ | |
-exec sh -c '(jpegtran -copy all -optimize -outfile "{}.jpg" "{}")' ';' | |
This file contains hidden or 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
#!/bin/bash | |
# Find all PNG files and do stuff with https://github.com/pornel/pngquant/ | |
find . -maxdepth 4 -type f -iname '*.png' \ | |
-exec sh -c '(pngquant --skip-if-larger "{}")' ';' | |
This file contains hidden or 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
#!/bin/bash | |
# Find the files just created and drop the extra suffix | |
find . -maxdepth 4 -type f -iname '*.jpg.jpg' \ | |
-exec sh -c '(hoplaa={}; mv -f "{}" "${hoplaa%.jpg}")' ';' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment