Skip to content

Commit

Permalink
Update bookdir2pdf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaid committed Jul 7, 2020
1 parent 70f6fe4 commit 8133a6b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bookdir2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,15 @@ def get_valid_filename(s):
page_list.append(p)
print("\tDone scanning directory!")

# Get number of pages
num_pages = len([p for p in page_list if os.path.isfile(p)])
print("\tPage count: {}".format(num_pages))

# Run purification (save to temporary directory)
if purify:
print()
print("-------- PURIFICATION --------")
print("Saving purified images to temporary directory: {}".format(final_input_dir))

# Delete temp dir (or file with same name) if it already exists
if os.path.exists(final_input_dir):
Expand Down Expand Up @@ -375,7 +380,7 @@ def get_valid_filename(s):
# It's an image file
with Image.open(p) as page_im:
if purify:
print("[PURIFY]: {}".format(p))
print("[PURIFY] ({}/{}): {}".format(x+1, num_pages, p))
# Make greyscale
gray = page_im.convert('L')

Expand Down Expand Up @@ -404,9 +409,6 @@ def get_valid_filename(s):
with Image.open(page_list_files[0]) as cover:
width, height = cover.size

# Get number of pages
num_pages = len(page_list_files)

# Create nested ordered dictionary from list
page_dict = OrderedDict()
for p in page_list:
Expand Down

0 comments on commit 8133a6b

Please sign in to comment.