I'm trying to detect width
and height
of an image before saving it to the database and S3. The image is in bytes
.
This is an example of an image before saved to Django
ImageField
:
NOTE: I don't want to use ImageField
s height_field
and width_field
as it slows down the server tremendously for some reason so I want to do it manually.
The image is downloaded using requests:
def download_image(url):
r = requests.get(url, stream=True)
r.raw.decode_content = True
return r.content