-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathimageResizeToMaxDimensionDir.sh
More file actions
executable file
·42 lines (35 loc) · 1.28 KB
/
imageResizeToMaxDimensionDir.sh
File metadata and controls
executable file
·42 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
source @includes.sh
echo '###################################################'
echo '# Description: Resize images to a maximum dimension'
echo '# Usage: $ ./imageResizeDirToMaxDimension.sh /path/to/images 640'
echo '# Param 1: Directory of images'
echo '# Param 2: Maximum width/height'
echo '# Requires: Imagemagick'
echo '###################################################'
echoNewline
################################################################################
################################################################################
# check parameters
if [[ $1 == "" ]] ; then
echoError '1st arg must be a directory'
exit 1
fi
if [[ $2 -eq 0 ]] ; then
echoError '2nd arg must be maximum size'
exit 1
fi
################################################################################
################################################################################
# loop through files
for file in "$1"/*.{png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF,heic,HEIC}
do
if [ -f $file ]; then
imageResizeToMaxDimension.sh "$file" $2
fi
done
################################################################################
################################################################################
# complete
echoSuccess "Success: Resized files in: $1"
# say Images resized