plt.imshow + plt.axis('off') + plt.show() is the preview. Not Image.show().
Goal
Show a gradient and print ok.
from PIL import Image
im = Image.new('RGB', (90, 90), (0, 0, 0))
for y in range(90):
for x in range(90):
im.putpixel((x, y), (x * 2, y * 2, 80))
plt.imshow(im)
plt.axis('off')
plt.show()
print('ok')from PIL import Image
plt.imshow(Image.new('RGB', (20, 10), (255, 200, 0)))
plt.axis('off')
plt.show()
print('ok')