Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exif_transpose errors out on some images #3973

Closed
okor opened this issue Jul 16, 2019 · 11 comments · Fixed by #4947
Closed

exif_transpose errors out on some images #3973

okor opened this issue Jul 16, 2019 · 11 comments · Fixed by #4947
Labels
Projects

Comments

@okor
Copy link

okor commented Jul 16, 2019

What did you do?

Used new exif_transpose method.

What did you expect to happen?

I expected a transposed image to be returned, without error.

What actually happened?

An error was raised.

/Users/okor/thumbor/lib/python2.7/site-packages/PIL/TiffImagePlugin.py:612: UserWarning: Metadata Warning, tag 282 had too many entries: 2, expected 1
  tag, len(values)))
/Users/okor/thumbor/lib/python2.7/site-packages/PIL/TiffImagePlugin.py:612: UserWarning: Metadata Warning, tag 283 had too many entries: 2, expected 1
  tag, len(values)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/okor/thumbor/lib/python2.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
    transposed_image.info["exif"] = exif.tobytes()
  File "/Users/okor/thumbor/lib/python2.7/site-packages/PIL/Image.py", line 3087, in tobytes
    return b"Exif\x00\x00"+head+ifd.tobytes(offset)
  File "/Users/okor/thumbor/lib/python2.7/site-packages/PIL/TiffImagePlugin.py", line 818, in tobytes
    count = len(data)
TypeError: object of type 'int' has no len()

Note that this error is not raised for all images. Only some. I'm not sure how the EXIF data differs.

What are your OS, Python and Pillow versions?

  • OS: macOS Mojave 10.14.5
  • Python: 2.7.16
  • Pillow: 6.0.0
from PIL import Image, ImageOps

im = Image.open('10_years_of_Wikipedia_by_Guillaume_Paumier.jpg')
im = ImageOps.exif_transpose(im)

10_years_of_Wikipedia_by_Guillaume_Paumier.jpg.zip


This error was encountered when attempting to replace piexif exif functionality with new Pillow functionality. The PR and conversation is here thumbor/thumbor#1209

@kkopachev
Copy link
Contributor

There are multiple issues in there, all with saving back exif info.
Reproducible with pillow's own images:

im = Image.open('Tests/images/exif_gps_typeerror.jpg')
# or use another one for different error
# im = Image.open('Tests/images/exif_gps.jpg')

# TypeError thrown
im.getexif().tobytes()

I figured few of the issues and working on a fix.
To outline what I've found:

  • Wrong type for GPSInfoIFD field in TiffTags
  • Usage of ImageFileDirectory_v1 which does not support saving RATIONAL/SRATIONAL as saving are done in ImageFileDirectory_v2 which expects different format - not tuple, but IFDRational.
  • Wrong handling of SRATIONAL type both with decoding and encoding
  • Wrong limitations for handling RATIONAL type
  • All other IFDs are silently dropped on save. Only saves Exif.

@hayzem
Copy link

hayzem commented Oct 1, 2019

run into the same error but seems like there is already a fix for it. #4009
I will check if it is resolving my issue.

@radarhere
Copy link
Member

The original error should be fixed now that #4009 is merged.

@radarhere radarhere changed the title exif_transpose method errors out on some images exif_transpose errors out on some images Oct 3, 2019
facebook-github-bot pushed a commit to facebookresearch/detectron2 that referenced this issue Nov 21, 2019
Summary:
There is a bug in Pillow not yet fixed when exif-transposing images:

python-pillow/Pillow#3973

and this can crash the whole training, this PR is to catch the bug and ignore and use the image as is

I believe that if the exif data was valuable for the user, he will check before hand that they are correct, so this PR should not impact anything meaniningfull

error to be fixed:

```
Original Traceback (most recent call last):
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/common.py", line 39, in __getitem__
    data = self._map_func(self._dataset[cur_idx])
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/dataset_mapper.py", line 74, in __call__
    image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/detection_utils.py", line 49, in read_image
    image = ImageOps.exif_transpose(image)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
    transposed_image.info["exif"] = exif.tobytes()
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/Image.py", line 3213, in tobytes
    return b"Exif\x00\x00" + head + ifd.tobytes(offset)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/TiffImagePlugin.py", line 837, in tobytes
    count = len(data)
TypeError: object of type 'int' has no len()
```
Pull Request resolved: #361

Differential Revision: D18630767

Pulled By: ppwwyyxx

fbshipit-source-id: 79ec76454ee853a2dbd82c750071b69ff535df53
ashnair1 added a commit to ashnair1/detectron2 that referenced this issue Nov 26, 2019
* small improvements; update docs;

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/329

Differential Revision: D18505473

Pulled By: ppwwyyxx

fbshipit-source-id: b41f0e8809c25f4cf2bfedae9af4c3735ea7d429

* display filename on image size mismatch

Summary: Pull Request resolved: facebookresearch#318

Differential Revision: D18505768

Pulled By: ppwwyyxx

fbshipit-source-id: 2f210eeb813e72b4f24962b43fdd71c489594c0b

* check black version; lint codebase (fix facebookresearch#322, fix facebookresearch#323)

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/330

Differential Revision: D18525378

Pulled By: ppwwyyxx

fbshipit-source-id: 5b25d0a214cf41bac63157104d5dae5e7923b81d

* update docs

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/331

Differential Revision: D18572260

Pulled By: ppwwyyxx

fbshipit-source-id: 39d340f726912255b186c3f0f20f939ff02a2cc0

* catch and ignore potential exif transpose bug (facebookresearch#361)

Summary:
There is a bug in Pillow not yet fixed when exif-transposing images:

python-pillow/Pillow#3973

and this can crash the whole training, this PR is to catch the bug and ignore and use the image as is

I believe that if the exif data was valuable for the user, he will check before hand that they are correct, so this PR should not impact anything meaniningfull

error to be fixed:

```
Original Traceback (most recent call last):
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/common.py", line 39, in __getitem__
    data = self._map_func(self._dataset[cur_idx])
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/dataset_mapper.py", line 74, in __call__
    image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/detection_utils.py", line 49, in read_image
    image = ImageOps.exif_transpose(image)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
    transposed_image.info["exif"] = exif.tobytes()
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/Image.py", line 3213, in tobytes
    return b"Exif\x00\x00" + head + ifd.tobytes(offset)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/TiffImagePlugin.py", line 837, in tobytes
    count = len(data)
TypeError: object of type 'int' has no len()
```
Pull Request resolved: facebookresearch#361

Differential Revision: D18630767

Pulled By: ppwwyyxx

fbshipit-source-id: 79ec76454ee853a2dbd82c750071b69ff535df53

* Updated git clone line in install instructions (facebookresearch#367)

Summary:
Get the following when I run `git clone git@github.com:facebookresearch/detectron2.git`. Replaced line with `git clone https://github.com/facebookresearch/detectron2.git`.

```bash
git clone git@github.com:facebookresearch/detectron2.git
Cloning into 'detectron2'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```
Pull Request resolved: facebookresearch#367

Differential Revision: D18646068

Pulled By: ppwwyyxx

fbshipit-source-id: 3254dda0a6386cfa3a17fdda0e875f6badeee26a

* update docs

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/332

Differential Revision: D18656747

Pulled By: ppwwyyxx

fbshipit-source-id: 145d45a7624222a40f14087de2a8793b6ec50473

* donot modify boxes in `BoxMode.convert`. (fix facebookresearch#334)

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/333

Differential Revision: D18672750

Pulled By: ppwwyyxx

fbshipit-source-id: 679fe082eed795f51ec9aead20f96737f46b4daa

* GUI support for docker. (facebookresearch#379)

Summary:
Thanks for the great repo! I very much like the easy set up via docker. However, one of the first things I did, was to figure out a way to display stuff like images or plots, without having to save them as images. I thought this might be interestering to others as well.

Kind regards.
Pull Request resolved: facebookresearch#379

Differential Revision: D18673252

Pulled By: ppwwyyxx

fbshipit-source-id: 4934fae9be0fe778bd1425340a15320ec3fa9bd2

* Updated proposal loading to avoid sorting (facebookresearch#363)

Summary:
Updated the code and docstring for loading precomputed proposals. The docstring now mentions the format of the proposal dict so that it is easier for users to add their own region proposal files. The loading code no longer requires the proposal dict be sorted in the same order as the dataset.
Pull Request resolved: facebookresearch#363

Differential Revision: D18676355

Pulled By: ppwwyyxx

fbshipit-source-id: 2b17d8d3f8d18be07037faac323b01434534417e

* Include RLE conversion in `instances_to_coco_json`

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/334

Test Plan:
```
./dev/run_inference_tests.sh configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml

python tools/train_net.py --config-file configs/LVIS-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml --num-gpus 2 --eval-only MODEL.WEIGHTS ~/data/D2models/LVIS-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/144219072/model_final_571f7c.pkl
```

Differential Revision: D18676571

Pulled By: ppwwyyxx

fbshipit-source-id: b36e92b7173b9b094731524951d071fef032d5ff

* Fix bug in class GeneralizedRCNNWithTTA. (facebookresearch#386)

Summary:
In multi-gpu training, the model is wrapped with DDP.
```
# For training, wrap with DDP. But don't need this for inference.
if comm.get_world_size() > 1:
    model = DistributedDataParallel(
        model, device_ids=[comm.get_local_rank()], broadcast_buffers=False
    )
```
Or [see here](https://github.com/facebookresearch/detectron2/blob/master/detectron2/engine/defaults.py#L229).

Therefore, when set cfg.TEST.AUG.ENABLED to True, the input model of GeneralizedRCNNWithTTA is instance of DistributedDataParallel rather than GeneralizedRCNN.
```
if cfg.TEST.AUG.ENABLED:
    trainer.register_hooks(
        [hooks.EvalHook(0, lambda: trainer.test_with_TTA(cfg, trainer.model))]
)
```
Or [see here](https://github.com/facebookresearch/detectron2/blob/master/tools/train_net.py#L145).

In this case, it brings errors in class GeneralizedRCNNWithTTA, such as "AssertionError: TTA is only supported on GeneralizedRCNN. Got a model of type <class 'torch.nn.parallel.distributed.DistributedDataParallel'>".

Thanks for your contribution!

If you're sending a large PR (e.g., >50 lines),
please open an issue first about the feature / bug, and indicate how you want to contribute.

Before submitting a PR, please run `dev/linter.sh` to lint the code.
Pull Request resolved: facebookresearch#386

Differential Revision: D18680342

Pulled By: ppwwyyxx

fbshipit-source-id: c1b10440f6d93c23302fd9b012b66216be8132c8

* Detectron2 Model Zoo API (Proposal for facebookresearch#270). (facebookresearch#274)

Summary:
Fixes facebookresearch#270.

### Introducing Model Zoo API:

- All configs in top-level `config` directory will be copied over to `detectron2/model_zoo` during `pip install` or `python setup.py install/develop`.

The API looks like:

```python
import detectron2.model_zoo as d2mz

model = d2mz.get("COCO-Detection/mask_rcnn_R_50_FPN_1x.yaml", trained=True)
```
Pull Request resolved: facebookresearch#274

Test Plan: buck test mode/dev-nosan //vision/fair/detectron2/tests:test_model_zoo

Reviewed By: rbgirshick

Differential Revision: D18654952

Pulled By: ppwwyyxx

fbshipit-source-id: b2694cf99013c43ce9acaeb5ad1da573b3936d4e

* Fix area calculation error in convert_to_coco_dict (facebookresearch#355)

Summary:
Fixes: facebookresearch#349

The constructor of `Boxes`  needs the bbox in `BoxMode.XYXY_ABS` mode.
This error will cause incorrect area calculation in `convert_to_coco_dict`.
I added a line converting the original bbox to XYXY_ABS before constructing `Boxes`.
Pull Request resolved: facebookresearch#355

Differential Revision: D18682061

Pulled By: ppwwyyxx

fbshipit-source-id: f115784825671d385a04ae4c5167c05609f46d85

* expose select_foreground_proposals & fix lint (close facebookresearch#395)

Summary: Pull Request resolved: https://github.com/fairinternal/detectron2/pull/335

Differential Revision: D18691035

Pulled By: ppwwyyxx

fbshipit-source-id: e199058753d271f0a9ece1d49f46601c8a4501ff

* TMask: Main (facebookresearch#268)

Summary:
TensorMask, main implementation.
Pull Request resolved: https://github.com/fairinternal/detectron2/pull/268

Reviewed By: rbgirshick

Differential Revision: D17229589

Pulled By: endernewton

fbshipit-source-id: cad8909945d41fe9896f0d0022a9595d1fb03a4f
@thuzhf
Copy link

thuzhf commented Nov 30, 2019

@radarhere The original error is still not fixed in version 6.2.1. I encountered the same error when I upgraded pillow to version 6.2.1 (python version is 3.7.3).
image

@radarhere
Copy link
Member

@thuzhf it is fixed in master, and will be a part of Pillow 7.0.0 when it is released on January 1.

@thuzhf
Copy link

thuzhf commented Nov 30, 2019

I see. Thanks.

thanhhvnqb pushed a commit to thanhhvnqb/detectron2 that referenced this issue Dec 13, 2019
Summary:
There is a bug in Pillow not yet fixed when exif-transposing images:

python-pillow/Pillow#3973

and this can crash the whole training, this PR is to catch the bug and ignore and use the image as is

I believe that if the exif data was valuable for the user, he will check before hand that they are correct, so this PR should not impact anything meaniningfull

error to be fixed:

```
Original Traceback (most recent call last):
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/common.py", line 39, in __getitem__
    data = self._map_func(self._dataset[cur_idx])
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/dataset_mapper.py", line 74, in __call__
    image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/detection_utils.py", line 49, in read_image
    image = ImageOps.exif_transpose(image)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
    transposed_image.info["exif"] = exif.tobytes()
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/Image.py", line 3213, in tobytes
    return b"Exif\x00\x00" + head + ifd.tobytes(offset)
  File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/TiffImagePlugin.py", line 837, in tobytes
    count = len(data)
TypeError: object of type 'int' has no len()
```
Pull Request resolved: facebookresearch#361

Differential Revision: D18630767

Pulled By: ppwwyyxx

fbshipit-source-id: 79ec76454ee853a2dbd82c750071b69ff535df53
@radarhere
Copy link
Member

radarhere commented Dec 31, 2019

From the earlier list -

@kkopachev can this issue be closed, or would you like to provide some more detail on any work you think is left to be done here?

@kkopachev
Copy link
Contributor

I think one item remains:

  • All other IFDs are silently dropped on save. Only saves Exif.

So saving is still broken, it does not respect nested IFDs structure. Given the file attached to this issue, there are some value-only tags in IFD0 as well as pointer to ExifIFD, with EXIF private tags, which in turns include GPSInfoIFD pointer. Saving loaded exif essentially flattens nested IFD structure making it invalid.

Example code:

from PIL import Image
from PIL.Image import Exif

im = Image.open('10_years_of_Wikipedia_by_Guillaume_Paumier.jpg')
good_exif = im.getexif()

bad_bytes = good_exif.tobytes()

bad_exif = Exif()
bad_exif.load(bad_bytes)

print("Good exif dictionary size: %d" % len(good_exif.get_ifd(34665)))
print(" Bad exif dictionary size: %d" % len(bad_exif.get_ifd(34665)))

assert(len(bad_exif.get_ifd(34665)) == len(good_exif.get_ifd(34665)))

Prints a bunch of warnings complaining about corrupt exif data in second load and at the end prints:

Good exif dictionary size: 26
 Bad exif dictionary size: 1

craymichael added a commit to craymichael/detectron2 that referenced this issue Jun 23, 2020
Workaround for the PIL bug python-pillow/Pillow#3973 - the exif orientation metadata is used to correctly transpose a PIL image when reading an image. The current approach silences any exceptions here, leading to strange behavior, such as issue facebookresearch#933. This is indeed a PIL issue, but the fix here performs the same function that is necessary to correctly orient images. The only differences between the committed function `apply_exif_orientation`  and the PIL `exif_transpose` is that a copy of the image is not generated if no transpose is needed, and that the exif data is not updated in the transposed image. As `read_image` returns a NumPy ndarray, this information is discarded, anyway.
facebook-github-bot pushed a commit to facebookresearch/detectron2 that referenced this issue Jun 26, 2020
Summary:
Workaround for the PIL bug python-pillow/Pillow#3973 - the exif orientation metadata is used to correctly transpose a PIL image when reading an image. The current approach silences any exceptions here, leading to strange behavior, such as issue #933. This is indeed a PIL issue, but the fix here performs the same function that is necessary to correctly orient images. The only differences between the committed function `apply_exif_orientation`  and the PIL `exif_transpose` is that a copy of the image is not generated if no transpose is needed, and that the exif data is not updated in the transposed image. As `read_image` returns a NumPy ndarray, this information is discarded, anyway.
Pull Request resolved: #1666

Differential Revision: D22238978

Pulled By: ppwwyyxx

fbshipit-source-id: 497c97b99fbfcf9857cbdf7516df10da4b42278d
@radarhere
Copy link
Member

I've created #4862 to save subIFDs. However, it does not address the flattening issue.

@kkopachev
Copy link
Contributor

@radarhere Got my hands on testing saving subIFDs and it looks great.
However, resaving exif data is still broken, because data from ExifIFD is unpacked into values of 0th IFD on Exif object. https://github.com/python-pillow/Pillow/blob/master/src/PIL/Image.py#L3337 . So the structure is:

0th IFD
|- tag1
|- tag2
|- ExifIFD
   | - orientation
   | - another_tag

Current code unpacks it into:

0th IFD
|- tag1
|- tag2
|- ExifIFD (this becomes just LONG of position of ExifIFD)
| - orientation
| - another_tag

So now, when dumping it back to bytes, it's all flattened.

Simple fix would be to to stop doing that and treat ExifIFD as indeed sub IFD

Index: src/PIL/Image.py
<+>UTF-8
===================================================================
--- src/PIL/Image.py	(revision c2367400fa8aab47d7752f3780681fced044f0d2)
+++ src/PIL/Image.py	(date 1600885150704)
@@ -3334,7 +3334,7 @@
         # get EXIF extension
         ifd = self._get_ifd_dict(0x8769)
         if ifd:
-            self._data.update(ifd)
+            self._data[0x8769] = ifd
             self._ifds[0x8769] = ifd
 
     def tobytes(self, offset=8):

But that would break backward compatibility, since in order to read orientation one would need to read ExifIFD first.

Or another option would be to try reading from 0th IFD for a tag and if that does not exist fallback to reading from ExifIFD.

What do you think would be desired approach to fix this problem?

@radarhere
Copy link
Member

It does break backwards compatibility, but the current behaviour loses information, and so I would hold that it's ultimately incorrect.

However, I also think that you're wrong about orientation? I think it's not part of the EXIF IFD, and is there with or without flattening.

See what you think of #4947. It fixes the flattening for getexif(), while keeping things as they are for _getexif().

d-fence added a commit to odoo-dev/odoo that referenced this issue Feb 5, 2021
On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009
robodoo pushed a commit to odoo/odoo that referenced this issue Feb 5, 2021
On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

closes #65584

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Feb 5, 2021
On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

X-original-commit: b83c48d
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Feb 5, 2021
On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

X-original-commit: b83c48d
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Feb 5, 2021
On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

X-original-commit: b83c48d
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Feb 5, 2021
On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

X-original-commit: b83c48d
Pillow automation moved this from In progress to Closed Mar 19, 2021
@radarhere radarhere mentioned this issue Nov 26, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

5 participants