-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf_Img.py
More file actions
38 lines (29 loc) · 1.29 KB
/
Copy pathpdf_Img.py
File metadata and controls
38 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import PyPDF2
import cv2
def check(x):
match x:
case 1:
pdf_files = input("Enter the PDF filenames to merge (separated by space): ").split()
merger = PyPDF2.PdfMerger()
for filename in pdf_files:
try:
with open(filename, "rb") as pdf_file:
merger.append(pdf_file)
except FileNotFoundError:
print(f"Error: '{filename}' not found. Skipping...")
output_filename = "merged.pdf"
merger.write(output_filename)
merger.close()
print(f" PDFs merged successfully into '{output_filename}'")
case 0:
source = input("Enter the Image name you want to resize: ")
destination = input("Enter the new name for image: ")
scale_percent = 50
src = cv2.imread(source, cv2.IMREAD_UNCHANGED)
new_w = int(src.shape[1] * scale_percent / 100)
new_h = int(src.shape[0] * scale_percent / 100)
output = cv2.resize(src, (new_w, new_h))
cv2.imwrite(destination, output)
print("You Can do Your Image Resizing And PDF Merging Here !")
a = int(input("Enter 0 for Image resizing Or 1 for PdfMerger: "))
check(a)