cdcvd commited on
Commit
74cc02c
1 Parent(s): c89663f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -6,6 +6,10 @@ from docx import Document
6
  from rembg import remove
7
  import gradio as gr
8
  import os
 
 
 
 
9
 
10
  # ایجاد دایرکتوری static
11
  os.makedirs("static", exist_ok=True)
@@ -17,13 +21,12 @@ def trim_whitespace(image):
17
  return trimmed_image
18
 
19
  def convert_pdf_to_images(pdf_path, zoom=2):
20
- try:
21
 
22
- pdf_document = fitz.open(pdf_path)
23
- name_with_extension = os.path.basename(pdf_path)
24
- name = os.path.splitext(name_with_extension)[0]
25
- images = []
26
- for page_num in range(len(pdf_document)):
27
  page = pdf_document.load_page(page_num)
28
  matrix = fitz.Matrix(zoom, zoom)
29
  pix = page.get_pixmap(matrix=matrix)
@@ -32,10 +35,6 @@ def convert_pdf_to_images(pdf_path, zoom=2):
32
  images.append(trimmed_image)
33
  return images
34
 
35
- import os
36
- from io import BytesIO
37
- from docx import Document
38
- from PIL import Image
39
 
40
  def convert_docx_to_jpeg(docx_bytes):
41
  """
 
6
  from rembg import remove
7
  import gradio as gr
8
  import os
9
+ import os
10
+ from io import BytesIO
11
+ from docx import Document
12
+ from PIL import Image
13
 
14
  # ایجاد دایرکتوری static
15
  os.makedirs("static", exist_ok=True)
 
21
  return trimmed_image
22
 
23
  def convert_pdf_to_images(pdf_path, zoom=2):
24
+
25
 
26
+ pdf_document = fitz.open(pdf_path)
27
+
28
+ images = []
29
+ for page_num in range(len(pdf_document)):
 
30
  page = pdf_document.load_page(page_num)
31
  matrix = fitz.Matrix(zoom, zoom)
32
  pix = page.get_pixmap(matrix=matrix)
 
35
  images.append(trimmed_image)
36
  return images
37
 
 
 
 
 
38
 
39
  def convert_docx_to_jpeg(docx_bytes):
40
  """