Skip to content

Commit

Permalink
Fix PNG bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy Sudarsono authored and Billy Sudarsono committed Aug 27, 2023
1 parent 883ffac commit da38a3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gerobug_dashboard/dashboards/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ def init_cert_db():
certdata.officer_title = "Founder of Gerobug"
certdata.save()

gerocert.gerocert.generate_sample()
log_config()
logging.debug("Init Certificate Data success")

else:
log_config()
logging.debug("Certificate Data already exists")

gerocert.gerocert.generate_sample()

# INIT MAILBOX
def init_mailbox_db():
Expand Down
4 changes: 4 additions & 0 deletions gerobug_dashboard/gerocert/gerocert.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def create_cert(name: str, certificate: str, severity):
# VALIDATE FORMAT
file_mime_type = magic.from_file(signature_path, mime=True)
if file_mime_type == "image/png":
if SIGNATURE.mode is not 'RGBA':
SIGNATURE.convert("RGBA")
img.paste(SIGNATURE, (int(x_name-10), int(y_name-(SIGNATURE.height+50))), mask=SIGNATURE)
elif file_mime_type == "image/jpeg" or file_mime_type == "image/jpg":
img.paste(SIGNATURE, (int(x_name-10), int(y_name-(SIGNATURE.height+50))))
Expand All @@ -101,6 +103,8 @@ def create_cert(name: str, certificate: str, severity):
# VALIDATE FORMAT
file_mime_type = magic.from_file(logo_path, mime=True)
if file_mime_type == "image/png":
if LOGO.mode is not 'RGBA':
LOGO.convert("RGBA")
img.paste(LOGO, (int(image_width / 17), int(y_name-215)), mask=LOGO)
elif file_mime_type == "image/jpeg" or file_mime_type == "image/jpg":
img.paste(LOGO, (int(image_width / 17), int(y_name-215)))
Expand Down

0 comments on commit da38a3f

Please sign in to comment.