-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript
More file actions
executable file
·88 lines (69 loc) · 2.43 KB
/
script
File metadata and controls
executable file
·88 lines (69 loc) · 2.43 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
# Copyright (c) 2023 chris1111 All rights reserved.
# Credit: Apple Image Processing System (sips)
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# Vars
Output="$HOME/Desktop/Resize_Images"
TempDir="/Private/tmp/Resize"
echo "Welcome Resize Images
-----------------------
---------------------------------------------------------------
Drop your images to resize them, only PNG, JPEG, TIFF, ICNS, HEIC images are accept.
An unlimited number of images can be dropped.
The images will be resized to the size you have chosen of High Quality.
Output folder ➤ $Output
---------------------------------------------------------------"
# Set Droping directory and file
for files in "$@" ;do
if [ "/Private/tmp/Resize" ]; then
rm -rf "${TempDir}"
fi
mkdir -p "${TempDir}"
Sleep 1
cp -R "$@" "${TempDir}"
read -r -d '' applescriptCode <<'EOF'
set dialogText to text returned of (display dialog "
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
⬇︎ Exemple size:
***************
16
32
64
128
256
512
1024
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Choose the size you want for your images.
Type your choice in the dialog box.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" default answer "" with icon 2)
return dialogText
EOF
dialogText=$(osascript -e "$applescriptCode");
osascript <<EOD
tell application "Resize Images"
activate
end tell
EOD
mkdir -p $Output
for file in "${TempDir}"/*;
do
sips -z $dialogText $dialogText -s dpiWidth 144 -s dpiHeight 144 "${TempDir}/${file##*/}" --out "$Output"
done
echo "
---------------------------------------------------------------
Resizing images at $dialogText (Px) ➤ $Output
---------------------------------------------------------------"
open -R $Output
Sleep 2
exit 0
done