Last active
July 15, 2016 14:16
-
-
Save lym/970cbde55b24c7ffab16037420c7f819 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
def _check_meter_image(self, meter_image): # meter_image is a base64-encoded string | |
err_msg = 'Please take a photograph of the meter' | |
if meter_image: | |
pre_img = base64.encodestring(bytearray(meter_image, 'utf8')) | |
pre_img2 = base64.decodestring(pre_img) | |
img_file = io.BytesIO(pre_img2) | |
img = Image.open(img_file) | |
print(img.filename) | |
if img.format == 'JPEG': | |
return True | |
else: | |
self._log_error(self.errors, err_msg) | |
else: | |
self._log_error(self.errors, err_msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment