Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #391: imghdr fails to recognize jpeg formats #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions htpc/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def download_image(url, dest, auth=None, headers=None):
def resize_image(img, height, width, opacity, dest):
""" Resize image, set opacity and save to disk """
size = int(width), int(height)
imagetype = imghdr.what(img)
im = Image.open(img)
imagetype = im.format
im = im.resize(size, Image.ANTIALIAS)

# Apply overlay if opacity is set
Expand All @@ -100,7 +100,8 @@ def resize_image(img, height, width, opacity, dest):
# apply overlay to resized image
im = Image.blend(overlay, im, enhance)

if imagetype == 'jpeg':
im.save(dest, 'JPEG', quality=95)
im.save(dest, imagetype)
if imagetype == 'JPEG':
im.save(dest, imagetype, quality=95)
else:
im.save(dest, imagetype)
return dest