【发布时间】:2013-05-27 11:23:13
【问题描述】:
我正在尝试调整图像大小。它工作正常,但我的ImageField,即to_field,正在打开但没有关闭。所以我有一个错误too many open files。我尝试了一些变通解决方案,但无法解决问题。代码如下:
if( to_field.width != size[0] and to_field.height != size[1] ):
to_field.open()
image = Image.open(StringIO(to_field.read()))
old_file_path = to_field.path
image.resize(size).save(to_field.path)
有什么建议吗??
【问题讨论】:
-
你/应该
image.close()吗? (不熟悉PIL...) -
是的,我试过了。没有“关闭”属性
标签: python django python-imaging-library