相关疑难解决方法(0)

Python-Wand序列无法从内存中清除

如果我做以下事情

for root, dirs, files in os.walk(myDir):
  for myFile in files:
    with Image(filename=myFile) as img:
      with Image(image=img) as main:
        print main.sequence[0].width
Run Code Online (Sandbox Code Playgroud)

我使用Wand最终导致内存故障.

我确定它的.sequence部分.如果我删除它,它的罚款.我已经阅读了所有我能在序列上找到的内容,它是一个Image vs SingleImage.

SingleImage序列部分保留在内存中.我试过使用以下内容:

main.sequence[0].destroy()
Run Code Online (Sandbox Code Playgroud)

但它并没有摆脱记忆中的形象.

我正在处理数千个文件,但是在几十个文件之后我就会出现分段错误.

我很确定它关闭了'主'图像.只是不是main.sequence SingleImage.

有办法强行关闭吗?

我应该说我也试过这个

with Image(image=img.sequence[0]) as main:
Run Code Online (Sandbox Code Playgroud)

认为With语句将间接关闭它.但事实并非如此.

有人可以帮忙吗?

imagemagick wand

7
推荐指数
1
解决办法
1456
查看次数

如何将 wand.image.Image 转换为 PIL.Image?

我在这个问题上花了一整天,但在堆栈溢出中没有看到答案!

我试过这个,但没有用:

    >> pil_image = Image.frombytes('RGBA', wand_image.size, wand_image.make_blob(format='png'), 'raw')

    ValueError: not enough image data
Run Code Online (Sandbox Code Playgroud)

我很欣赏每一个解决方案。

python type-conversion python-imaging-library wand

4
推荐指数
2
解决办法
2126
查看次数