Skip to content

Commit e7e672f

Browse files
author
dn0z
committed
Fixed a few minor bugs
1 parent 74505a1 commit e7e672f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

bir.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# https://github.com/dn0z/Batch-Image-Resize
66

77
import os
8-
from PIL import Image
8+
import PIL.Image
99
from tkinter import *
1010
from tkinter import ttk
1111
from tkinter import filedialog
@@ -68,7 +68,7 @@ def get_filename_with_type(self, filename, file_type, suffix=""):
6868
"""
6969

7070
extension = filename.split(".")[-1]
71-
return filename[:-len(extension)] + suffix + "." + file_type.lowercase()
71+
return filename[:-(len(extension) + 1)] + suffix + "." + file_type.lower()
7272

7373
def export_file(self, path, name, width, height, export_type, overwrite):
7474
"""
@@ -85,17 +85,16 @@ def export_file(self, path, name, width, height, export_type, overwrite):
8585
img_path = os.path.join(path, name)
8686

8787
# open the given image and resize it
88-
img = Image.open(img_path)
89-
img = img.resize((width, height), Image.ANTIALIAS)
88+
img = PIL.Image.open(img_path)
89+
img = img.resize((width, height), PIL.Image.ANTIALIAS)
9090

9191
# set the destination image file we want to save
9292
dest_img_name = self.get_filename_with_type(name, export_type, "_resized")
9393
if overwrite:
9494
dest_img_name = name
9595

9696
# save the resized/converted image
97-
print("Save to " + os.path.join(path, dest_img_name))
98-
# img.save(os.path.join(path, dest_img_name))
97+
img.save(os.path.join(path, dest_img_name))
9998

10099
def init_export(self):
101100
"""
@@ -117,6 +116,7 @@ def init_export(self):
117116
for path, subdirs, files in os.walk(directory_path):
118117
for name in files:
119118
if self.is_image(name):
119+
# TODO: Add a new window with a progress bar while exporting images
120120
self.export_file(path, name, width, height, export_type, overwrite)
121121

122122
# at this point, we are done with our exports, display a success message

0 commit comments

Comments
 (0)