deldesir / calibre-web-old

:books: Web app for browsing, reading and downloading eBooks, videos, pictures and audio stored in a Calibre database
GNU General Public License v3.0
0 stars 0 forks source link

Uploading most (all?) PNG's, many PDF's (other file formats too?) causes "500 Internal Server Error" "image has wrong mode" #19

Open holta opened 1 year ago

holta commented 1 year ago

While the PNG itself is successfully uploaded (if one bypassed the browser error message below) a thumbnail/cover is not created:

Internet in a Box
500 Internal Server Error
The server encountered an internal error and was unable to complete your request. There is an error in the application.

Traceback (most recent call last):
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/calibre-web-py3/cps/usermanagement.py", line 34, in decorated_view
    return func(*args, **kwargs)
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 64, in inner
    return f(*args, **kwargs)
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 282, in upload
    move_coverfile(meta, db_book)
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 764, in move_coverfile
    result = cropper.crop(image, 150, 150)
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/smartcrop/library.py", line 164, in crop
    result = self.analyse(
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/smartcrop/library.py", line 90, in analyse
    cie_image = image.convert('L', (0.2126, 0.7152, 0.0722, 0))
  File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/PIL/Image.py", line 930, in convert
    im = self.im.convert_matrix(mode, matrix)
ValueError: image has wrong mode
thadk commented 1 year ago

Also seeing this for a PDF. Is it possible the image is blank? Maybe some debug information on that object as it is going into crop could be useful.

``` [2023-08-08 16:57:56,039] ERROR {cps:1414} Exception on /upload [POST] Traceback (most recent call last): File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app response = self.full_dispatch_request() File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/usr/local/calibre-web-py3/cps/usermanagement.py", line 34, in decorated_view return func(*args, **kwargs) File "/usr/local/calibre-web-py3/cps/editbooks.py", line 65, in inner return f(*args, **kwargs) File "/usr/local/calibre-web-py3/cps/editbooks.py", line 283, in upload move_coverfile(meta, db_book) File "/usr/local/calibre-web-py3/cps/editbooks.py", line 767, in move_coverfile result = cropper.crop(image, 150, 150) File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/smartcrop/library.py", line 164, in crop result = self.analyse( File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/smartcrop/library.py", line 90, in analyse cie_image = image.convert('L', (0.2126, 0.7152, 0.0722, 0)) File "/usr/local/calibre-web-py3/lib/python3.10/site-packages/PIL/Image.py", line 930, in convert im = self.im.convert_matrix(mode, matrix) ValueError: image has wrong mode ```
holta commented 1 year ago

@EMG70 likewise tried to upload simple PDF's (teacher's worksheets for electricity learning) and while each PDF does in fact upload, most PDF's result in these long/ugly "500 Internal Server Error" "image has wrong mode" errors every time.

(The pattern is repeatable: a few PDF's work [generating a thumbnail image, and uploading the PDF cleanly] but in his experience most PDF's do not.)

image

image