Created
June 24, 2010 23:50
-
-
Save niallo/452168 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 _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