1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-10-20 10:07:39 +00:00

Fix #1068 PDF cover Images inverted or incorrect single image grabbed from cover page

This commit is contained in:
Ozzieisaacs
2019-11-03 09:49:54 +01:00
parent 6f61e80c97
commit a7ab7fcf06
2 changed files with 7 additions and 118 deletions

View File

@@ -54,7 +54,7 @@ except ImportError:
use_unidecode = False
try:
from PIL import Image
from PIL import Image as PILImage
use_PIL = True
except ImportError:
use_PIL = False
@@ -497,9 +497,9 @@ def save_cover(img, book_path):
# convert to jpg because calibre only supports jpg
if content_type in ('image/png', 'image/webp'):
if hasattr(img,'stream'):
imgc = Image.open(img.stream)
imgc = PILImage.open(img.stream)
else:
imgc = Image.open(io.BytesIO(img.content))
imgc = PILImage.open(io.BytesIO(img.content))
im = imgc.convert('RGB')
tmp_bytesio = io.BytesIO()
im.save(tmp_bytesio, format='JPEG')