Pillow 6.2.2 and 7.0.0 jpg save

Created on 17 Jan 2020  路  3Comments  路  Source: python-pillow/Pillow

What did you do?

Running existing code after an update to the newest version of the Pillow package and trying to save the resulting plot as a jpgimage.

What did you expect to happen?

savefig('image.jpg') correctly saving an image in the jpg format as usual.

What actually happened?

With Pillow version 7.0.0, returned error:
ValueError: Format 'jpg' is not supported (supported formats: eps, pdf, pgf, png, ps, raw, rgba, svg, svgz)
The error is not present and plot is saved correctly after downgrading to version 6.2.2

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 16.04
  • Python: 3.5.2
  • Pillow: 6.2.2 (working), 7.0.0 (not working)

Fails even with this minimal code:

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(15,10))
fig.savefig('test.jpg')
Removal

Most helpful comment

https://github.com/matplotlib/matplotlib/pull/16086#issuecomment-575826240 reports that matplotlib 3.1.3 should be released by end of day tomorrow. So after that, you should simply be able to update matplotlib to resolve this.

All 3 comments

Thanks for the report.

This is because Pillow 7.0.0 removed PILLOW_VERSION, which the current latest matplotlib==3.1.2 uses to check if Pillow is installed.

This has been fixed in matplotlib in https://github.com/matplotlib/matplotlib/pull/16086, and should be released in the next matplotlib 3.1.x and 3.2.0.

In the meantime, either:

https://github.com/matplotlib/matplotlib/pull/16086#issuecomment-575826240 reports that matplotlib 3.1.3 should be released by end of day tomorrow. So after that, you should simply be able to update matplotlib to resolve this.

Thank you @hugovk and @radarhere for your replies. For now I will stick with older version of Pillow as it works well for my current needs and make a move to never matplotlib in the future.

Was this page helpful?
0 / 5 - 0 ratings