Python,PIL和JPEG在Heroku上

编程入门 行业动态 更新时间:2024-10-26 21:21:17
本文介绍了Python,PIL和JPEG在Heroku上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 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上

本文发布于:2023-06-08 06:30:17,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PIL   Python   Heroku   JPEG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!