Skip to content

Commit efb5f68

Browse files
fns added
1 parent 86c7588 commit efb5f68

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Backend/NotesToText.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,22 @@
22

33

44
# Create an instance of APIRouter
5-
router = APIRouter()
5+
router = APIRouter()
6+
7+
def pdf_to_images(pdf_path, output_folder):
8+
# Convert PDF pages to images
9+
images = convert_from_path(pdf_path)
10+
11+
# Create the output folder if it doesn't exist
12+
if not os.path.exists(output_folder):
13+
os.makedirs(output_folder)
14+
15+
# Save each image in the specified output folder
16+
image_paths = []
17+
for i, image in enumerate(images):
18+
image_path = os.path.join(output_folder, f'page_{i+1}.jpeg')
19+
image.save(image_path, 'JPEG')
20+
image_paths.append(image_path)
21+
noImg = i+1
22+
23+
return image_paths,noImg

0 commit comments

Comments
 (0)