{"action":"created","issue":{"url":"https://api.github.com/repos/python-pillow/Pillow/issues/2065","repository_url":"https://api.github.com/repos/python-pillow/Pillow","labels_url":"https://api.github.com/repos/python-pillow/Pillow/issues/2065/labels{/name}","comments_url":"https://api.github.com/repos/python-pillow/Pillow/issues/2065/comments","events_url":"https://api.github.com/repos/python-pillow/Pillow/issues/2065/events","html_url":"https://github.com/python-pillow/Pillow/issues/2065","id":170316399,"number":2065,"title":"Guess mimetype from image bytes","user":{"login":"naaaargle","id":7771981,"avatar_url":"https://avatars.githubusercontent.com/u/7771981?v=3","gravatar_id":"","url":"https://api.github.com/users/naaaargle","html_url":"https://github.com/naaaargle","followers_url":"https://api.github.com/users/naaaargle/followers","following_url":"https://api.github.com/users/naaaargle/following{/other_user}","gists_url":"https://api.github.com/users/naaaargle/gists{/gist_id}","starred_url":"https://api.github.com/users/naaaargle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naaaargle/subscriptions","organizations_url":"https://api.github.com/users/naaaargle/orgs","repos_url":"https://api.github.com/users/naaaargle/repos","events_url":"https://api.github.com/users/naaaargle/events{/privacy}","received_events_url":"https://api.github.com/users/naaaargle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-10T02:49:25Z","updated_at":"2016-08-21T09:18:59Z","closed_at":null,"body":"I recently worked with images and needed to derive the mimetype of an image when I did not have the file name. I had the file bytes, and came up with a way to hack together a best guess mimetype:\r\n```python\r\ndef guess_mimetype(image_data):\r\n    extension = \".{}\".format(Image.open(StringIO.StringIO(image_data)).format)\r\n    return mimetypes.types_map.get(extension.lower(), None)\r\n```\r\nI'm wondering if there's a place in this repo for such a feature? I looked through `Image.py` and I'm not sure it makes sense to go there organizationally, but if this is would be useful I can try to find a place and put in a PR.\r\n\r\nIf this doesn't belong in Pillow, is there another library where it would fit in well?"},"comment":{"url":"https://api.github.com/repos/python-pillow/Pillow/issues/comments/241247186","html_url":"https://github.com/python-pillow/Pillow/issues/2065#issuecomment-241247186","issue_url":"https://api.github.com/repos/python-pillow/Pillow/issues/2065","id":241247186,"user":{"login":"arjennienhuis","id":15640868,"avatar_url":"https://avatars.githubusercontent.com/u/15640868?v=3","gravatar_id":"","url":"https://api.github.com/users/arjennienhuis","html_url":"https://github.com/arjennienhuis","followers_url":"https://api.github.com/users/arjennienhuis/followers","following_url":"https://api.github.com/users/arjennienhuis/following{/other_user}","gists_url":"https://api.github.com/users/arjennienhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/arjennienhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arjennienhuis/subscriptions","organizations_url":"https://api.github.com/users/arjennienhuis/orgs","repos_url":"https://api.github.com/users/arjennienhuis/repos","events_url":"https://api.github.com/users/arjennienhuis/events{/privacy}","received_events_url":"https://api.github.com/users/arjennienhuis/received_events","type":"User","site_admin":false},"created_at":"2016-08-21T09:18:59Z","updated_at":"2016-08-21T09:18:59Z","body":"I think this library does what you want:\r\n\r\nhttps://github.com/ahupp/python-magic"}}
{"actor":{"display_login":"arjennienhuis"}}