1 parent 74df0dc commit 160412dCopy full SHA for 160412d
1 file changed
scripts/pdf_to_cbz.py
@@ -63,9 +63,12 @@ def convert_pdf_to_image_directory(pdf_path):
63
page_count = int(pdfinfo_from_path(pdf_path)["Pages"])
64
for index in range(1, page_count + 1):
65
image = convert_from_path(pdf_path, first_page=index, last_page=index)[0]
66
- output_filename = f"{pdf_name}_{index:03}.png"
67
- output_path = os.path.join(output_directory, output_filename)
68
- image.save(output_path, "PNG")
+ try:
+ output_filename = f"{pdf_name}_{index:03}.png"
+ output_path = os.path.join(output_directory, output_filename)
69
+ image.save(output_path, "PNG")
70
+ finally:
71
+ image.close()
72
73
return output_directory
74
0 commit comments