我有一个 Django 网站,托管在 Heroku 上。 其中一个模型具有图像字段,可以上传图像,调整大小,并将它们推送到Amazon S3,以便可以持久存储它们。
使用 PIL 可以很好地工作
然而,PIL似乎对PNG和GIF工作正常,但不会与 libjpeg 合并。在本地开发环境或完全控制的'nix服务器上,仅仅是安装jpeg扩展的情况。 但是有谁知道使用Cedar Heroku堆栈是否可以进行Jpeg操作?还有其他的东西可以添加到requirements.txt中吗?
在其他不相关的包中,这个virtualenv的requirements.txt包括:
Django == 1.3.1 PIL == 1.1.7 distribute == 0.6.24 django-queued- storage == 0.5 django-storages == 1.1.4 psycopg2 == 2.4.4 python-dateutil == 1.5 wsgiref == 0.1.2 谢谢解决方案
在requirements.txt中使用这个PIL分支:
-e hg + https://bitbucket/etienned/pil -2009-raclette /#egg = PIL 并且可以使用JPEG而不会产生任何问题:
------------------------------- ------------------------------------- PIL 1.2a0安装摘要 -------------------------------------------------- ------------------ 版本1.2a0 平台Python 2.7.2(默认,2011年10月31日,16:22:04) [GCC 4.4.3] on linux2 -------------------------------------- ------------------------------ *** TKINTER支持不可用 --- JPEG支持可用 ***不支持WEBP支持 ---支持ZLIB(PNG / ZIP) ---支持FREETYPE2 ---支持LITTLECMS ------------------------------------------------- -------------------
I have a Django site, hosted on Heroku.
One of the models has an image field, that takes uploaded images, resizes them, and pushes them to Amazon S3 so that they can be stored persistently.
This is working well, using PIL
def save(self, *args, **kwargs):
# Save this one
super(Product, self).save(*args,**kwargs)
# resize on file system
size = 200, 200
filename = str(self.thumbnail.path)
image = Image.open(filename)
image.thumbnail(size, Image.ANTIALIAS)
image.save(filename)
# send to amazon and remove from ephemeral file system
if put_s3(filename):
os.remove(filename)
return True
However, PIL seems to work fine for PNGs and GIFs, but is not compliled with libjpeg. On a local development environment or a fully controlled 'nix server, it is simply a case of installing the jpeg extension.
But does anyone know whether Jpeg manipulation is possible using the Cedar Heroku stack? Is there something else that can be added to requirements.txt?
Among other unrelated packages, the requirements.txt for this virtualenv includes:
Django==1.3.1
PIL==1.1.7
distribute==0.6.24
django-queued-storage==0.5
django-storages==1.1.4
psycopg2==2.4.4
python-dateutil==1.5
wsgiref==0.1.2
Thanks
解决方案 I use this PIL fork in requirements.txt:
-e hg+bitbucket/etienned/pil-2009-raclette/#egg=PIL
and can use JPEG without issues:
--------------------------------------------------------------------
PIL 1.2a0 SETUP SUMMARY
--------------------------------------------------------------------
version 1.2a0
platform Python 2.7.2 (default, Oct 31 2011, 16:22:04)
[GCC 4.4.3] on linux2
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** WEBP support not available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
--------------------------------------------------------------------
更多推荐
Python,PIL和JPEG在Heroku上
发布评论