Skip to content

Commit

Permalink
fix bug: save img from file list
Browse files Browse the repository at this point in the history
  • Loading branch information
nachifur committed Nov 23, 2021
1 parent 9022499 commit cfd6a70
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions utils_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,14 +1444,7 @@ def save_select(self, dir_name):
f_path = self.path_list[self.action_count *
self.count_per_action+i_]
try:
i = 0
for stem in Path(f_path)._cparts:
if i == 0:
str_ = str(self.action_count *
self.count_per_action+i_)+"_"+stem
i += 1
else:
str_ = str_+"_"+stem
str_ = Path(f_path).parent.stem+"_"+Path(f_path).name

if self.layout_params[11]:
move(f_path, Path(self.out_path_str) / "select_images" /
Expand Down Expand Up @@ -1493,20 +1486,9 @@ def save_select(self, dir_name):
self.get_flist()

def save_stitch(self, dir_name):
name_f = self.get_stitch_name()
if self.type == 3:
name_f = self.path_list[self.action_count*self.count_per_action]
i = 0
for stem in Path(name_f)._cparts:
if i == 0:
str_ = str(self.action_count *
self.count_per_action)+"_"+stem
i += 1
else:
str_ = str_+"_"+stem
name_f = str_
name_f = str(Path(name_f).with_suffix(".png"))
else:
name_f = self.get_stitch_name()
name_f = "from_file_"+name_f
f_path_output = Path(self.out_path_str) / dir_name / name_f
if not (Path(self.out_path_str)/dir_name).is_dir():
os.makedirs(Path(self.out_path_str) / dir_name)
Expand Down Expand Up @@ -1561,25 +1543,16 @@ def save_magnifier(self, dir_name):
f_path = self.path_list[self.action_count *
self.count_per_action+i_]
i = 0
img_name = ""
for stem in Path(f_path)._cparts:
if i == 0:
str_ = str(self.action_count *
self.count_per_action+i_)+"_"+stem
else:
if i == len(Path(f_path)._cparts)-1:
img_name = stem
else:
str_ = str_+"_"+stem
i += 1

str_ = Path(f_path).parent.stem+"_"+Path(f_path).stem

img = self.img_list[i_]
img_list = self.magnifier_preprocessing(
self.img_preprocessing(img, id=self.get_img_id(i_)), img_mode=1)
i = 0
for img in img_list:
f_path_output = Path(
self.out_path_str) / dir_name/sub_dir_name / (str_+"_"+Path(img_name).stem+"_magnifier_"+str(i)+".png")
self.out_path_str) / dir_name/sub_dir_name / (str_+"_magnifier_"+str(i)+".png")
img.save(f_path_output)
i += 1
else:
Expand Down

0 comments on commit cfd6a70

Please sign in to comment.