-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimg_size_rate_calc.py
62 lines (42 loc) · 1.18 KB
/
img_size_rate_calc.py
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
# pylint: disable=C0111
# ↑プログラムの説明ドキュメントがないよ!というエラーの防止
# pylint: disable=W0312
# ↑Found indentation with tabs instead of spacesを防止
#import glob
import sys
import os
import numpy as np
import cv2
import mbiocv2 as mb
#import pprint as pp
class images:
def __init__(self):
self.filename = []
self.h = np.empty(0, dtype=np.int)
self.w = np.empty(0, dtype=np.int)
self.hpw = np.empty(0, dtype=np.float)
self.wph = np.empty(0, dtype=np.float)
self.max_h = 0
self.max_w = 0
def calc_rate(self):
self.hpw = []
def main():
argv = sys.argv
argc = len(sys.argv)
for n in range(1,argc):
#print(sys.argv[n])
collage = mb.imread(argv[n])
if (collage is None):
print("Warning:[{}]の読み込み失敗".format(argv[n]) )
else:
h = collage.shape[0]
w = collage.shape[1]
hpw = h/w
wph = w/h
filename = os.path.basename(argv[n])
print("ファイル名:{:>20}, 高:{:>5}, 幅:{:>5}, 高/幅:{:>5.3f}, 幅/高:{:>5.3f}".format(
filename, h, w, hpw, wph)
)
input("終")
if __name__ == "__main__":
sys.exit(main())