Skip to content

Instantly share code, notes, and snippets.

@reedobrien
Created December 5, 2011 19:43
Show Gist options
  • Save reedobrien/1434982 to your computer and use it in GitHub Desktop.
Save reedobrien/1434982 to your computer and use it in GitHub Desktop.
def is_really_image(node, value):
request = get_current_request()
tmpstore = MongoTmpStore(request)
image_uid = value['uid']
fp = tmpstore[image_uid]['fp']
fp.seek(0)
try:
Image.open(fp)
except IOError:
raise colander.Invalid(
node,
'"%s" is not an image file' % value['filename'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment