collective / experimental.gracefulblobmissing

Gracefully handle missing BLOBs in Plone
https://pypi.org/project/experimental.gracefulblobmissing/
2 stars 1 forks source link

Create tiny image instead of text when creating a missing blob #5

Closed mauritsvanrees closed 2 years ago

mauritsvanrees commented 2 years ago

When using this package in development, I get lots of errors in the log like this:

2021-10-20 11:06:17,168 ERROR   [root:132][waitress-1] could not scale "<plone.namedfile.file.NamedBlobImage object at 0x12775df20 oid 0x26756c in <Connection at 108173610>>" of 'http://localhost:8080/es/front-page'
Traceback (most recent call last):
  File "/Users/maurits/shared-eggs/cp38/plone.app.tiles-3.2.0-py3.8.egg/plone/app/tiles/imagescaling.py", line 123, in create
    result = scaleImage(
  File "/Users/maurits/shared-eggs/cp38/plone.scale-3.1.2-py3.8.egg/plone/scale/scale.py", line 57, in scaleImage
    image = PIL.Image.open(image)
  File "/Users/maurits/shared-eggs/cp38/Pillow-6.2.2-py3.8-macosx-10.15-x86_64.egg/PIL/Image.py", line 2818, in open
    raise IOError("cannot identify image file %r" % (filename if filename else fp))
OSError: cannot identify image file <_io.BytesIO object at 0x127768f40>

The site works fine, I see no errors in the browser, but the errors in the log/foreground are annoying. Currently the package sets a string in a missing blob: "File created by experimental.gracefulblobmissing."

Would it be okay to fill the 'fake' blob with a small image instead? I guess just the Plone logo, either in PNG or JPEG. Or maybe just one pixel.

ale-rt commented 2 years ago

I did something similar in the past: https://github.com/collective/experimental.gracefulblobmissing/tree/auto-create-images

thet commented 2 years ago

I had a need for this feature and did a rebase on current master on the branch auto-create-images--rebased. PR here: https://github.com/collective/experimental.gracefulblobmissing/pull/6

mauritsvanrees commented 2 years ago

Released a few days ago in version 1.0.