Skip to content

Commit

Permalink
fix: images from pdf in png for videobooks
Browse files Browse the repository at this point in the history
  • Loading branch information
R3gm committed Jul 18, 2024
1 parent f5db52c commit 7a70621
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion soni_translate/text_multiformat_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def add_border_to_image(

bordered_img = ImageOps.expand(resized_img, padding, fill=border_color)

bordered_img.save(image_path)
bordered_img.save(image_path, format='PNG')

return image_path

Expand Down Expand Up @@ -506,6 +506,8 @@ def doc_to_txtximg_pages(
images = []
for image_file_object in page.images:
img_name = f"{images_folder}{i:04d}_{count:02d}_{image_file_object.name}"
if not img_name.lower().endswith('.png'):
img_name = os.path.splitext(img_name)[0] + '.png'
images.append(img_name)
with open(img_name, "wb") as fp:
fp.write(image_file_object.data)
Expand Down

0 comments on commit 7a70621

Please sign in to comment.