check if wand is available, add dummy cover.jpg otherwise
This commit is contained in:
parent
e4ffc9f2a0
commit
51f1453917
12
cps/web.py
12
cps/web.py
@ -21,9 +21,14 @@ from functools import wraps
|
||||
import base64
|
||||
from sqlalchemy.sql import *
|
||||
import json
|
||||
from wand.image import Image
|
||||
import datetime
|
||||
from uuid import uuid4
|
||||
try:
|
||||
from wand.image import Image
|
||||
use_generic_pdf_cover = False
|
||||
except ImportError, e:
|
||||
use_generic_pdf_cover = True
|
||||
from shutil import copyfile
|
||||
|
||||
app = (Flask(__name__))
|
||||
|
||||
@ -776,6 +781,11 @@ def upload():
|
||||
file_size = os.path.getsize(saved_filename)
|
||||
has_cover = 0
|
||||
if fileextension.upper() == ".PDF":
|
||||
if use_generic_pdf_cover:
|
||||
basedir = os.path.dirname(__file__)
|
||||
print basedir
|
||||
copyfile(os.path.join(basedir, "static/generic_cover.jpg"), os.path.join(filepath, "cover.jpg"))
|
||||
else:
|
||||
with Image(filename=saved_filename + "[0]", resolution=150) as img:
|
||||
img.compression_quality = 88
|
||||
img.save(filename=os.path.join(filepath, "cover.jpg"))
|
||||
|
Loading…
Reference in New Issue
Block a user