|
|
@ -62,7 +62,11 @@ except ImportError as e:
|
|
|
|
logger.warning('cannot import fb2, extracting fb2 metadata will not work: %s', e)
|
|
|
|
logger.warning('cannot import fb2, extracting fb2 metadata will not work: %s', e)
|
|
|
|
use_fb2_meta = False
|
|
|
|
use_fb2_meta = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
from PIL import Image
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
use_PIL = True
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
|
|
|
use_PIL = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process(tmp_file_path, original_file_name, original_file_extension):
|
|
|
|
def process(tmp_file_path, original_file_name, original_file_extension):
|
|
|
@ -133,6 +137,7 @@ def pdf_preview(tmp_file_path, tmp_dir):
|
|
|
|
if use_generic_pdf_cover:
|
|
|
|
if use_generic_pdf_cover:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
if use_PIL:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
input1 = PdfFileReader(open(tmp_file_path, 'rb'), strict=False)
|
|
|
|
input1 = PdfFileReader(open(tmp_file_path, 'rb'), strict=False)
|
|
|
|
page0 = input1.getPage(0)
|
|
|
|
page0 = input1.getPage(0)
|
|
|
@ -173,7 +178,6 @@ def pdf_preview(tmp_file_path, tmp_dir):
|
|
|
|
# img.save(obj[1:] + ".png")
|
|
|
|
# img.save(obj[1:] + ".png")
|
|
|
|
except Exception as ex:
|
|
|
|
except Exception as ex:
|
|
|
|
print(ex)
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cover_file_name = os.path.splitext(tmp_file_path)[0] + ".cover.jpg"
|
|
|
|
cover_file_name = os.path.splitext(tmp_file_path)[0] + ".cover.jpg"
|
|
|
|
with Image(filename=tmp_file_path + "[0]", resolution=150) as img:
|
|
|
|
with Image(filename=tmp_file_path + "[0]", resolution=150) as img:
|
|
|
|