Email attachments are failing for some images of files that have transparency
raceback (most recent call last):
File "apps/frappe/frappe/utils/background_jobs.py", line 134, in execute_job
method(**kwargs)
File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 959, in pull_from_email_account
email_account.receive()
File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 399, in receive
raise Exception(frappe.as_json(exceptions))
Exception: [
"Traceback (most recent call last):\n File \"env/lib/python3.8/site-packages/PIL/JpegImagePlugin.py\", line 630, in _save\n rawmode = RAWMODE[im.mode]\nKeyError: 'RGBA'\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 366, in receive\n communication = self.insert_communication(msg, args=args)\n File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 509, in insert_communication\n communication._attachments = email.save_attachments_in_doc(communication)\n File \"apps/frappe/frappe/email/receive.py\", line 587, in save_attachments_in_doc\n _file.save()\n File \"apps/frappe/frappe/model/document.py\", line 310, in save\n return self._save(*args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 332, in _save\n return self.insert()\n File \"apps/frappe/frappe/model/document.py\", line 254, in insert\n self.run_method(\"before_insert\")\n File \"apps/frappe/frappe/model/document.py\", line 941, in run_method\n out = Document.hook(fn)(self, *args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 1260, in composer\n return composed(self, method, *args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 1242, in runner\n add_to_return_value(self, fn(self, *args, **kwargs))\n File \"apps/frappe/frappe/model/document.py\", line 938, in fn\n return method_object(*args, **kwargs)\n File \"apps/frappe/frappe/core/doctype/file/file.py\", line 73, in before_insert\n self.save_file(content=self.content, decode=self.decode)\n File \"apps/frappe/frappe/core/doctype/file/file.py\", line 469, in save_file\n self.content = strip_exif_data(self.content, self.content_type)\n File \"apps/frappe/frappe/utils/image.py\", line 44, in strip_exif_data\n new_image.save(output, format=content_type.split(\"/\")[1])\n File \"env/lib/python3.8/site-packages/PIL/Image.py\", line 2212, in save\n save_handler(self, fp, filename)\n File \"env/lib/python3.8/site-packages/PIL/JpegImagePlugin.py\", line 632, in _save\n raise OSError(f\"cannot write mode {im.mode} as JPEG\") from e\nOSError: cannot write mode RGBA as JPEG\n",
"Traceback (most recent call last):\n File \"env/lib/python3.8/site-packages/PIL/JpegImagePlugin.py\", line 630, in _save\n rawmode = RAWMODE[im.mode]\nKeyError: 'RGBA'\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 366, in receive\n communication = self.insert_communication(msg, args=args)\n File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 509, in insert_communication\n communication._attachments = email.save_attachments_in_doc(communication)\n File \"apps/frappe/frappe/email/receive.py\", line 587, in save_attachments_in_doc\n _file.save()\n File \"apps/frappe/frappe/model/document.py\", line 310, in save\n return self._save(*args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 332, in _save\n return self.insert()\n File \"apps/frappe/frappe/model/document.py\", line 254, in insert\n self.run_method(\"before_insert\")\n File \"apps/frappe/frappe/model/document.py\", line 941, in run_method\n out = Document.hook(fn)(self, *args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 1260, in composer\n return composed(self, method, *args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 1242, in runner\n add_to_return_value(self, fn(self, *args, **kwargs))\n File \"apps/frappe/frappe/model/document.py\", line 938, in fn\n return method_object(*args, **kwargs)\n File \"apps/frappe/frappe/core/doctype/file/file.py\", line 73, in before_insert\n self.save_file(content=self.content, decode=self.decode)\n File \"apps/frappe/frappe/core/doctype/file/file.py\", line 469, in save_file\n self.content = strip_exif_data(self.content, self.content_type)\n File \"apps/frappe/frappe/utils/image.py\", line 44, in strip_exif_data\n new_image.save(output, format=content_type.split(\"/\")[1])\n File \"env/lib/python3.8/site-packages/PIL/Image.py\", line 2212, in save\n save_handler(self, fp, filename)\n File \"env/lib/python3.8/site-packages/PIL/JpegImagePlugin.py\", line 632, in _save\n raise OSError(f\"cannot write mode {im.mode} as JPEG\") from e\nOSError: cannot write mode RGBA as JPEG\n"
]