mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 04:19:59 +00:00
check if wand is available, add dummy cover.jpg otherwise
This commit is contained in:
parent
e4ffc9f2a0
commit
51f1453917
20
cps/web.py
20
cps/web.py
@ -21,9 +21,14 @@ from functools import wraps
|
|||||||
import base64
|
import base64
|
||||||
from sqlalchemy.sql import *
|
from sqlalchemy.sql import *
|
||||||
import json
|
import json
|
||||||
from wand.image import Image
|
|
||||||
import datetime
|
import datetime
|
||||||
from uuid import uuid4
|
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__))
|
app = (Flask(__name__))
|
||||||
|
|
||||||
@ -776,10 +781,15 @@ def upload():
|
|||||||
file_size = os.path.getsize(saved_filename)
|
file_size = os.path.getsize(saved_filename)
|
||||||
has_cover = 0
|
has_cover = 0
|
||||||
if fileextension.upper() == ".PDF":
|
if fileextension.upper() == ".PDF":
|
||||||
with Image(filename=saved_filename + "[0]", resolution=150) as img:
|
if use_generic_pdf_cover:
|
||||||
img.compression_quality = 88
|
basedir = os.path.dirname(__file__)
|
||||||
img.save(filename=os.path.join(filepath, "cover.jpg"))
|
print basedir
|
||||||
has_cover = 1
|
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"))
|
||||||
|
has_cover = 1
|
||||||
is_author = db.session.query(db.Authors).filter(db.Authors.name == author).first()
|
is_author = db.session.query(db.Authors).filter(db.Authors.name == author).first()
|
||||||
if is_author:
|
if is_author:
|
||||||
db_author = is_author
|
db_author = is_author
|
||||||
|
Loading…
Reference in New Issue
Block a user