Signalen / backend

Backend for Signalen, an application that helps cities manage and prioritize nuisance reports.
https://signalen.org
Mozilla Public License 2.0
5 stars 5 forks source link

Backend throws an exception for generating a PDF with specific images #158

Open bartjkdp opened 3 years ago

bartjkdp commented 3 years ago

The backend throws the following exception when generating a PDF containing specific images:

File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "./signals/apps/api/pdf/views.py", line 11, in get
context = self.get_context_data(**kwargs)
File "./signals/apps/api/views/pdf.py", line 112, in get_context_data
jpg_data_uris = DataUriImageEncodeService.get_context_data_images(self.object, self.max_size)
File "./signals/apps/services/domain/images.py", line 59, in get_context_data_images
image.save(new_buffer, format='JPEG')
File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 2172, in save
save_handler(self, fp, filename)
File "/usr/local/lib/python3.8/site-packages/PIL/JpegImagePlugin.py", line 635, in _save
raise OSError(f"cannot write mode {im.mode} as JPEG") from e
OSError: cannot write mode RGBA as JPEG

For more details see report 13386 @ DB.