Created
November 13, 2020 03:18
-
-
Save pawiromitchel/1f77f2f0710453e11ace5ddbb8211d71 to your computer and use it in GitHub Desktop.
Resize image with imagemagic convert utility
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
#!/bin/bash | |
# find $1 -maxdepth 1 -name "*.jpg" => finds JPG images in the directory you give it (based on the $1 value) that the script is in | |
# $1 is the directory you give the script for example "./resize_image.sh /home/folder_to_optimize/" | |
for file in `find $1 -maxdepth 1 -name "*.jpg"` | |
do | |
# convert the image and replace the original one | |
# throttle 50 = only use 50% of the cpu power | |
# 2500x = max 2500px, height will be automatically be adjusted based on the width | |
convert -limit throttle 50 $file -resize 2500x -verbose $file | |
# delay van 0.5 sec | |
sleep 0.5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment