test-rtechs commited on
Commit
54accfc
·
verified ·
1 Parent(s): 31c69b4

Update soni_translate/text_multiformat_processor.py

Browse files
soni_translate/text_multiformat_processor.py CHANGED
@@ -357,7 +357,7 @@ def add_border_to_image(
357
 
358
  bordered_img = ImageOps.expand(resized_img, padding, fill=border_color)
359
 
360
- bordered_img.save(image_path)
361
 
362
  return image_path
363
 
@@ -506,6 +506,8 @@ def doc_to_txtximg_pages(
506
  images = []
507
  for image_file_object in page.images:
508
  img_name = f"{images_folder}{i:04d}_{count:02d}_{image_file_object.name}"
 
 
509
  images.append(img_name)
510
  with open(img_name, "wb") as fp:
511
  fp.write(image_file_object.data)
@@ -984,4 +986,4 @@ def break_aling_segments(
984
  )
985
  logger.info(msg_count)
986
 
987
- return break_segments
 
357
 
358
  bordered_img = ImageOps.expand(resized_img, padding, fill=border_color)
359
 
360
+ bordered_img.save(image_path, format='PNG')
361
 
362
  return image_path
363
 
 
506
  images = []
507
  for image_file_object in page.images:
508
  img_name = f"{images_folder}{i:04d}_{count:02d}_{image_file_object.name}"
509
+ if not img_name.lower().endswith('.png'):
510
+ img_name = os.path.splitext(img_name)[0] + '.png'
511
  images.append(img_name)
512
  with open(img_name, "wb") as fp:
513
  fp.write(image_file_object.data)
 
986
  )
987
  logger.info(msg_count)
988
 
989
+ return break_segments