# 伪代码
from psd_tools import PSDImage
def main():
for file in file_list:
save_jpg(file)
def save_jpg(file):
img = PSDImage.open(file).composite()
img.save(output_name)
save_jpg),运行正常。save_jpg里del img啥的也没什么用,我感觉save_jpg运行完一次应该就释放内存了。不知道是不是依赖库有问题,但有些 psd 直接用 PIL.Image 打不开,才用到的这个第三方库。 1
cocowind 2020 年 10 月 17 日
看源码有没有释放句柄
|
2
xchaoinfo 2020 年 10 月 17 日 via Android
with PSDImage.open
|
3
ipwx 2020 年 10 月 17 日
1. 请及时关闭不需要的东西。
2. 32 位程序只能用 2GB 用户态内存。请确信你用的不是 32 位 python 。 |
4
laike9m 2020 年 10 月 18 日
你需要的不是猜测,而是 profiling,推荐几个库吧:
https://github.com/pythonprofilers/memory_profiler https://mg.pov.lt/objgraph/ |
5
nonduality 2020 年 10 月 18 日
假如你尝试这么写呢?
```python def save_jpg(file): fd = PSDImage.open(file) fd.composite().save(output_name) fd.close() ``` |