Inconsistent images between PIL and imread()

Hi,

This was pointed out to me by David W-F on twitter: PIL and imread()
return images that are not consistent, but rather one is upside down
from the other. This is shown by the following code:

import PIL.Image
import matplotlib.pyplot as plt

plt.subplot(2, 2, 1)
plt.imshow(PIL.Image.open('Z.png'))
plt.title('PIL')

plt.subplot(2, 2, 2)
plt.imshow(plt.imread('Z.png'))
plt.title('imread (MPL for PNG)')

plt.subplot(2, 2, 3)
plt.imshow(PIL.Image.open('Andy_font.JPG'))
plt.title('PIL')

plt.subplot(2, 2, 4)
plt.imshow(plt.imread('Andy_font.JPG'))
plt.title('imread (PIL for JPEG)')

plt.show()

output.png contains the result of the script, where only one of the
images is rotated relative to the rest. While I'm quite willing to
accept the possibility that this is PIL weirdness and not MPL (or
maybe not), we still have the problem that
the proper way to display the output of imread depends on the format
of the image, since imread() falls back to PIL for anything but PNG.

Thoughts?

Ryan

Z.png

Andy_font.JPG

output.png

ยทยทยท

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma