我正在尝试使用Django Oscar,但我无法正确加载我的图像。一旦我上传了一张图片,我就会收到这个错误——"无法将RGBA模式写入JPEG"。错误来自第11行:
6 {% block product %}
7 <article class="product_pod">
8 {% block product_image %}
9 <div class="image_container">
10 {% with image=product.primary_image %}
11 {% oscar_thumbnail image.original "x155" upscale=False as thumb %} <!-- this line throwing error -->
12 <a href="{{ product.get_absolute_url }}">
13 <img src="{{ thumb.url }}" alt="{{ product.get_title }}" class="thumbnail">
14 </a>
15 {% endwith %}
16 </div>
17 {% endblock %}
这会是因为我没有正确安装libjpeg吗?我在Windows上运行这个程序,但我仍然不清楚我是否正确安装了libjpeg。如果这是我的问题,下载后我到底需要怎么处理这个包?
如果我能提供更多有用的信息,请告诉我。
我不确定这是否是正确的答案,但将django-oscar缩略图扩展名更改为Easy Thumbnails似乎暂时解决了我的问题。希望这能帮助其他可能遇到问题的人。Pypi网站的简单缩略图
THUMBNAIL_PRESERVE_FORMAT = True
来完成
THUMBNAIL_PRERVE_FORMAT
默认值:错误
如果为True,则将保留输入文件的格式。如果为False,将使用THUMBNAIL_FORMAT。
https://sorl-thumbnail.readthedocs.io/en/latest/reference/settings.html#thumbnail-保留格式