Advertisement
mayankjoin3

batch image resizer

Jun 14th, 2022
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Purpose: batch image resizer
  3. # Source: https://guides.wp-bullet.com
  4. # Author: Mike
  5.  
  6. # absolute path to image folder
  7. FOLDER="/var/www/html/key_issue_api/stud_img"
  8.  
  9. # max width
  10. WIDTH=540
  11.  
  12. # max height
  13. HEIGHT=300
  14.  
  15. #resize png or jpg to either height or width, keeps proportions using imagemagick
  16. #find ${FOLDER} -iname '*.jpg' -o -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
  17.  
  18. #resize png to either height or width, keeps proportions using imagemagick
  19. #find ${FOLDER} -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
  20.  
  21. #resize jpg only to either height or width, keeps proportions using imagemagick
  22. find ${FOLDER} -iname '*.jpg' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
  23.  
  24. # alternative
  25. #mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png -verbose
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement