Andrew Murray

Results 765 comments of Andrew Murray

Just to point it out - since the [removal of `PILLOW_VERSION`](https://pillow.readthedocs.io/en/stable/releasenotes/7.0.0.html#pillow-version-constant), which I think was the most backwards incompatible change that we've made, [some people are still working around that](https://github.com/python-pillow/Pillow/issues/4130#issuecomment-1201516416)...

After experimenting, I'm not convinced that it's possible to tell from within Pillow if `import PIL.Image` or `from PIL import Image` was used, without either using traceback, which I expect...

Trying the suggestion from the previous comment, I initially hit a circular import, but I was able to work around it. So the following code does allow `import PIL; PIL.Image`...

So, the code from the original post is about an interaction between matplotlib and Pillow. A matplotlib maintainer has weighed in on this and said that the behaviour is fine....

> why import PIL.Image works when matplotlib is imported first? It's not that `import PIL.Image` works differently, it's that `PIL.Image` works after importing `matplotlib`. It would be because [matplotlib internally...

This is hitting https://github.com/python-pillow/Pillow/blob/fce23ddce8a7e5be7625367678803db0288c3c8e/src/libImaging/Blend.c#L26-L30 Could you upload a copy of the image?

Ok. Be aware that's a PNG file with a palette, rather than a 16-bit TIFF, so that's different. If you would like an immediate solution, you can convert it to...

@ghoshben the previous comment suggests that converting is actually the ultimate solution here. Does that resolve this for you?

The same solution applies, just with some scaling in the middle to account for the fact that it is an I;16 image and [Pillow doesn't scale automatically when converting](https://github.com/python-pillow/Pillow/issues/3159). ```python...

@homm did you have any further thoughts?