Skip to content

Instantly share code, notes, and snippets.

@niallo
Created June 24, 2010 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niallo/452168 to your computer and use it in GitHub Desktop.
Save niallo/452168 to your computer and use it in GitHub Desktop.
def _get_image_mimetype(self, filename):
''' Use file(1) to determine the mimetype of the file '''
p = Popen(["file", "-i", filename], stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate()
mime_type = stdout.split(':')[1].strip()
return mime_type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment