Created
December 15, 2015 02:09
-
-
Save Andygmb/81076ea42e064057e288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_bytes = image.read(MIN_PNG_SIZE) | |
image.seek(0) | |
if first_bytes.startswith(PNG_HEADER): | |
image_type = 'png' | |
elif first_bytes.startswith(JPEG_HEADER): | |
image_type = 'jpg' | |
else: | |
raise errors.ClientException('`image` must be either jpg or ' | |
'png.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment