Skip to content

Commit eaf5d32

Browse files
authored
Merge pull request #713 from AnswerDotAI/fix/712
fix `detect_mime` missing import
2 parents 31819c9 + b476a71 commit eaf5d32

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

fastcore/xtras.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def img_bytes(img, fmt='PNG'):
154154
def detect_mime(data):
155155
"Get the MIME type for bytes `data`, covering common PDF, audio, video, and image types"
156156
import mimetypes
157+
from fastcore import imghdr
157158
for (sig,pos),mime in _sigs.items():
158159
if data[pos:pos+len(sig)]==sig: return mime(data) if callable(mime) else mime
159160
return mimetypes.types_map.get(f'.{imghdr.what(None, h=data)}')

nbs/03_xtras.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@
567567
"def detect_mime(data):\n",
568568
" \"Get the MIME type for bytes `data`, covering common PDF, audio, video, and image types\"\n",
569569
" import mimetypes\n",
570+
" from fastcore import imghdr\n",
570571
" for (sig,pos),mime in _sigs.items():\n",
571572
" if data[pos:pos+len(sig)]==sig: return mime(data) if callable(mime) else mime\n",
572573
" return mimetypes.types_map.get(f'.{imghdr.what(None, h=data)}')"

0 commit comments

Comments
 (0)