From 5271d1a2e1c7dc80e39644fbbdcdc2fe4c53aaaf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 13 Sep 2013 15:17:09 +0530 Subject: [PATCH] Recognize EMF images --- src/calibre/utils/imghdr.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/imghdr.py b/src/calibre/utils/imghdr.py index c4070f072e..fc8d0942d7 100644 --- a/src/calibre/utils/imghdr.py +++ b/src/calibre/utils/imghdr.py @@ -10,10 +10,10 @@ def what(file, h=None): if h is None: if isinstance(file, basestring): f = open(file, 'rb') - h = f.read(32) + h = f.read(44) else: location = file.tell() - h = file.read(32) + h = file.read(44) file.seek(location) f = None else: @@ -120,6 +120,12 @@ def test_bmp(h, f): tests.append(test_bmp) +def test_emf(h, f): + if h[:4] == b'\x01\0\0\0' and h[40:44] == b' EMF': + return 'emf' + +tests.append(test_emf) + #--------------------# # Small test program # #--------------------#