Last active
August 30, 2016 04:14
-
-
Save lackneets/2ad4b95e0c49cbd5b404 to your computer and use it in GitHub Desktop.
Remember some useful command
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
# Install imagemagick | |
sudo apt-get install imagemagick | |
# Resize jpeg images under subdirectories | |
find . -name "*.jpg" -exec mogrify -resize 1600x1600\> -quality 75% -verbose -format jpg {} + | |
# Resize jpeg images only if > 1MB | |
# http://superuser.com/questions/204564/how-can-i-find-files-that-are-bigger-smaller-than-x-bytes | |
find . -name "*.jpg" -size +1M -exec mogrify -resize 1600x1600\> -quality 75% -verbose -format jpg {} + | |
# Resize all images to 120x120 and output in another directory | |
find . -maxdepth 1 -regextype posix-egrep -regex ".*\.(png|jpg|gif)$" -exec \ | |
mogrify -verbose -resize 120x120\> -format png -path ./small {} + | |
# as above, force to square / No filling background | |
find . -maxdepth 1 -regextype posix-egrep -regex ".*\.(png|jpg|gif)$" -exec \ | |
mogrify -verbose -resize 120x120\> -gravity center -extent 120x120 -background none -format png -path ./small {} + | |
# resize, keepaspect ratio and fill blank space | |
find . -maxdepth 1 -regextype posix-egrep -regex ".*\.(png|jpg|gif)$" -exec \ | |
mogrify -verbose -resize 250x180 -background white -gravity center -extent 250x180\> -format png -path ./small {} + | |
# resize portrait to square | |
find . -maxdepth 1 -regextype posix-egrep -regex ".*\.(png|jpg|gif)$" -exec \ | |
mogrify -verbose -geometry x500 -background transparent -gravity center -extent 500x500\> -format png -path ./small {} + | |
# Make all files 644 and 755 for folders (security for Wordpress, PHP, website...) | |
find . -type d -exec chmod 755 {} \; | |
find . -type f -exec chmod 644 {} \; | |
# Rename to lowercase | |
find . -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment