Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated split image #293

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion python/prohibition_web_svc/middleware/event_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from python.prohibition_web_svc.business.cryptography_logic import encryptPdf_method1
import img2pdf
import uuid
from split_image import split_image


def validate_update(**kwargs) -> tuple:
Expand Down Expand Up @@ -267,9 +268,17 @@ def save_event_pdf(**kwargs) -> tuple:
pdf_filename = f"/tmp/{filename}.pdf"
encrypted_pdf_filename = f"/tmp/{filename}_encrypted.pdf"
b64encoded = data.get("VI_form_png").split(",")[1]
extra_page_flag=data.get('incident_details_extra_page',False)
page_num=3 if extra_page_flag else 2
with open(f"/tmp/{filename}.png", "wb") as fh:
fh.write(b64decode(b64encoded))
pdf_bytes = img2pdf.convert(f"/tmp/{filename}.png")
split_image(f"/tmp/{filename}.png", page_num, 1, False, True,output_dir="/tmp")
# pdf_bytes = img2pdf.convert(f"/tmp/{filename}.png")
pdf_bytes=None
if extra_page_flag:
pdf_bytes = img2pdf.convert(f"/tmp/{filename}_0.png", f"/tmp/{filename}_1.png", f"/tmp/{filename}_2.png")
else:
pdf_bytes = img2pdf.convert(f"/tmp/{filename}_0.png", f"/tmp/{filename}_1.png")
with open(pdf_filename, "wb") as file:
file.write(pdf_bytes)
encryptPdf_method1(
Expand Down
1 change: 1 addition & 0 deletions python/prohibition_web_svc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ PyMuPDF==1.23.3
pyaes==1.6.1
pbkdf2==1.3
img2pdf
split-image
Loading