mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 04:22:40 +01:00
implement fix-jpeg-detection:
detect jpeg files using their magic bytes following the unix file implementation by adding a test function to the imghdr.tests list, as intended
This commit is contained in:
parent
ab7c0321d6
commit
187b96edc0
1 changed files with 14 additions and 0 deletions
|
|
@ -270,6 +270,20 @@ def _sc_encode(gain, peak):
|
|||
|
||||
# Cover art and other images.
|
||||
|
||||
def _wider_test_jpeg(h, f):
|
||||
"""Test for a jpeg file following the UNIX file implementation which
|
||||
uses the magic bytes rather just than looking for the bytes b'JFIF'
|
||||
or b'EXIF' at a fixed position.
|
||||
"""
|
||||
if h[:2] == b'\xff\xd8':
|
||||
return 'jpeg'
|
||||
|
||||
# Add this new test function to the list of functions used by imghdr to
|
||||
# determine the mime type
|
||||
imghdr.tests.append(_wider_test_jpeg)
|
||||
|
||||
|
||||
|
||||
def _image_mime_type(data):
|
||||
"""Return the MIME type of the image data (a bytestring).
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue