Skip to content

Instantly share code, notes, and snippets.

View jairajsahgal's full-sized avatar

jairajsahgal jairajsahgal

View GitHub Profile
@jairajsahgal
jairajsahgal / compressing_image.py
Created September 30, 2023 18:58
This method is used to compress an image and return the image object.
def compress_image(image):
# Define your compression settings here
# For example, you can resize the image and adjust the quality
max_size = (800, 800)
quality = 80
# Resize the image while preserving aspect ratio
image.thumbnail(max_size, Image.ANTIALIAS)
# Convert the image to RGB mode (necessary for saving as JPEG)
@jairajsahgal
jairajsahgal / handler_example.py
Last active November 30, 2023 21:02
Handler Example
LOGGING = {
# ... (other logging configurations)
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
},
},
# ... (loggers, filters, and formatters)