bepasty-server icon indicating copy to clipboard operation
bepasty-server copied to clipboard

Thumbnail displays broken image in list view

Open luckman212 opened this issue 3 years ago • 8 comments

Not sure what my issue is here but, even if pasting a valid image, on the list view the Thumbnail is broken:

CleanShot 2021-10-04 at 09 28 53

The image seems to be "ok" - if you click Display/detail view: image

When navigating directly to the eg /XoPyMpQx/+thumbnail endpoint, In Chrome's console, this error is displayed, not sure if it matters: image

luckman212 avatar Oct 04 '21 13:10 luckman212

501 is "not implemented".

did you install bepasty with the optional pillow support? Like pip install bepasty[pillow].

ThomasWaldmann avatar Oct 04 '21 14:10 ThomasWaldmann

Hmm... ok, I reinstalled w/ pillow support, now it gives different results...

image

CleanShot 2021-10-04 at 10 37 07

image

in /home/bepasty/logs/gunicorn_supervisor.log:

[2021-10-04 14:39:15,320] ERROR in app: Exception on /XoPyMpQx/+thumbnail [GET]
Traceback (most recent call last):
  File "/home/bepasty/lib/python3.9/site-packages/PIL/JpegImagePlugin.py", line 629, in _save
    rawmode = RAWMODE[im.mode]
KeyError: 'RGBA'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bepasty/lib/python3.9/site-packages/flask/app.py", line 2070, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/bepasty/lib/python3.9/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/bepasty/lib/python3.9/site-packages/flask/app.py", line 1513, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/bepasty/lib/python3.9/site-packages/flask/app.py", line 1499, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/bepasty/lib/python3.9/site-packages/flask/views.py", line 83, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/bepasty/lib/python3.9/site-packages/flask/views.py", line 157, in dispatch_request
    return meth(*args, **kwargs)
  File "/home/bepasty/repo/src/bepasty/views/download.py", line 80, in get
    return self.response(item, name)
  File "/home/bepasty/repo/src/bepasty/views/download.py", line 121, in response
    img.save(thumbnail_bio, self.thumbnail_type)
  File "/home/bepasty/lib/python3.9/site-packages/PIL/Image.py", line 2235, in save
    save_handler(self, fp, filename)
  File "/home/bepasty/lib/python3.9/site-packages/PIL/JpegImagePlugin.py", line 631, in _save
    raise OSError(f"cannot write mode {im.mode} as JPEG") from e
OSError: cannot write mode RGBA as JPEG

luckman212 avatar Oct 04 '21 14:10 luckman212

the crossed-rectangle is expected, it is just a placeholder for stuff that can not be shown as thumbnail.

the traceback is unexpected though, last time i checked that worked for me.

what pillow version did you install?

ThomasWaldmann avatar Oct 04 '21 16:10 ThomasWaldmann

This is what I've got:

# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

# pip list
Package                    Version             Location
-------------------------- ------------------- ----------------------
bepasty                    1.0.1.dev9+g8f4c23f /home/bepasty/repo/src
click                      8.0.1
Flask                      2.0.1
gevent                     21.8.0
greenlet                   1.1.2
gunicorn                   20.1.0
itsdangerous               2.0.1
Jinja2                     3.0.1
MarkupSafe                 2.0.1
Pillow                     8.3.2
pip                        20.3.4
pkg-resources              0.0.0
Pygments                   2.10.0
setuptools                 44.1.1
Werkzeug                   2.0.1
wheel                      0.34.2
XStatic                    1.0.2
XStatic-asciinema-player   2.6.1.1
XStatic-Bootbox            5.5.1.1
XStatic-Bootstrap          4.5.3.1
XStatic-Font-Awesome       4.7.0.0
XStatic-jQuery             3.5.1.1
XStatic-jQuery-File-Upload 10.31.0.1
XStatic-jquery-ui          1.12.1.1
XStatic-Pygments           2.9.0.1
zope.event                 4.5.0
zope.interface             5.4.0

luckman212 avatar Oct 04 '21 17:10 luckman212

Maybe try an older pillow. That used to work.

Maybe filing an issue in pillow's issue tracker could also help.

ThomasWaldmann avatar Oct 06 '21 17:10 ThomasWaldmann

Thanks- Any particular pillow version that is known to work?

luckman212 avatar Oct 06 '21 19:10 luckman212

I tried to install the last 7.x version, but it fails to install w. Python3.9. Seems the oldest version I can install there is 8.0.0.

So I tried pip install Pillow==8.0.0 and restarted everything. Sadly, did not fix the broken thumbnails. Guess this is a dead end & needs to be opened with https://github.com/python-pillow/Pillow/issues ?

luckman212 avatar Oct 06 '21 19:10 luckman212

Yeah, please open an issue there. Maybe the code has some incompatible change or bepasty uses it in a problematic way.

ThomasWaldmann avatar Oct 07 '21 08:10 ThomasWaldmann

I tried this right now and it worked great for JPEGs, but not for PNG (I could reproduce your issue for these).

ThomasWaldmann avatar Jan 21 '23 22:01 ThomasWaldmann