使用get_rendition处理CMYK格式JPEG时出现Pillow报错
Hey there, let's unpack your question step by step:
1. How Wagtail Manages Pillow Dependencies
Wagtail does declare a dependency on Pillow in its setup.py, but for older versions like 1.13.x, the requirement is typically a minimum lower bound (I believe it's >=2.7.0 for that release) rather than a strict upper or specific version. The project's philosophy here is to support as many existing deployment environments as possible, so it avoids forcing newer library versions unless a core feature absolutely requires it.
2. Why You're Seeing the Production Error
Your custom rendition endpoint is likely using Pillow APIs or behaviors that changed between version 2.8.2 and 5.0.0. Since Wagtail allows older Pillow versions, it doesn't block this scenario—but your custom code has an implicit dependency on the newer Pillow functionality that isn't present in the production environment's older version. This isn't a Wagtail bug; it's a compatibility gap between your custom code and the older Pillow version you're running in production.
3. Should Wagtail Enforce a Higher Minimum Pillow Version?
Short answer: No, not for your specific case. Wagtail's core features are designed to work with the minimum required Pillow version it declares. If your custom code needs newer Pillow features, that's a project-specific requirement, not something Wagtail would enforce globally. The framework can't predict all custom use cases, so it leaves version pinning for such scenarios up to individual project maintainers.
4. Your Fix Is Completely Valid
Adding pillow>=5.0.0 to your production requirements.txt is the right approach here. This ensures your production environment matches your local development setup, eliminating the version mismatch that's causing the error. If you need to support older environments for some reason, you could also refactor your custom code to use Pillow 2.8.2-compatible APIs—but upgrading Pillow is almost always the simpler, more future-proof solution.
内容的提问来源于stack exchange,提问作者joss

