-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtiff2png.sh
executable file
·55 lines (41 loc) · 1006 Bytes
/
tiff2png.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
##########################################
#This script parse tif into IMG & LBL PNG#
#Maintainer: Christopher Chan #
#Date: 2022-02-17 #
#Version: 0.1.2 #
##########################################
echo "This script parse .tif into IMG & LBL PNGs"
echo "Please specify IMG directory: "
read -p "IMG dir: " IMG_dir
IMG_dir=${IMG_dir:- }
echo "Please specify LBL directory: "
read -p "LBL dir: " LBL_dir
LBL_dir=${LBL_dir:- }
# Extract b4 to LBL directory
echo "Extracting band 4 to LBL directory..."
cd $IMG_dir
for i in *.tif;
do
gdal_translate -of PNG -ot Byte -b 4 $i $LBL_dir"/"$i".png";
done
echo "Extracting band 1 2 3 to IMG directory..."
for i in *.tif;
do
gdal_translate -of PNG -ot Byte -b 1 -b 2 -b 3 $i $IMG_dir"/"$i".png";
done
rm -rf *.tif
# Renaming files
for i in *;
do
rename -v .tif "" $i;
done
cd $LBL_dir
for i in *;
do
rename -v _IMG_ _LBL_ $i;
done
for i in *;
do
rename -v .tif "" $i;
done