-
Notifications
You must be signed in to change notification settings - Fork 10
/
srg.sh
34 lines (25 loc) · 903 Bytes
/
srg.sh
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
#!/bin/bash
## Make globally available with:
# sudo cp srg.sh /usr/local/bin/srg
# sudo cp sRGB_v4_ICC_preference.icc /usr/local/bin/sRGB_v4_ICC_preference.icc
# sudo chmod a+x /usr/local/bin/srg
# Get the sRGB profile file from http://www.color.org/srgbprofiles.xalter
echo "== Convert to JPG with sRGB profile ==";
target_dir="srgb";
if [[ ! -d $target_dir ]]; then
mkdir $target_dir;
echo "Created $target_dir"
fi
for f in `find ./ -maxdepth 1 -type f \( -iname \*.jpg -o -iname \*.png -o -iname \*.tif \)`
do
# Trim the ./ part .
f=${f:2};
filename=$(basename $f);
new_filename="${filename%.*}.jpg"
target="${target_dir}/${new_filename}";
dir=$(dirname $f);
convert $f \
-posterize 64 -depth 8 \
-colorspace sRGB -profile /usr/local/bin/sRGB_v4_ICC_preference.icc $target
echo $target;
done