You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04.3 LTS中ImageMagick调用TextClip报错的解决求助

Ubuntu 22.04.3 LTS下ImageMagick生成TextClip报错解决方法

问题场景

在Ubuntu 22.04.3 LTS系统中已安装ImageMagick,用于给视频片段叠加文本,执行创建TextClip的代码时触发错误。

涉事代码片段

text_clip = TextClip(segment_transcript, font=TEXT_FONT, fontsize=TEXT_SIZE, color=TEXT_COLOR)
text_clip = text_clip.set_position(TEXT_POSITION).set_duration(cropped_clip.duration)

错误提示

convert-im6.q16: attempt to perform an operation not allowed by the security policy @/tmp/tmp8geu2egw.txt' @ error/property.c/InterpretImageProperties/3706. convert-im6.q16: no images defined PNG32:/tmp/tmpns_g05qt.png' @ error/convert.c/ConvertImageCommand/3229.

官方给出的可能原因:未安装ImageMagick,或(Windows用户)未在conf.py中指定ImageMagick二进制文件路径/路径错误。

解决步骤

  • 打开ImageMagick的策略配置文件:
    sudo nano /etc/ImageMagick-6/policy.xml
    
  • 找到限制@路径操作的配置行,通常是:
    <policy domain="path" rights="none" pattern="@*" />
    
  • 处理方式二选一:
    1. 直接注释掉该行(前后加注释标记):
      <!-- <policy domain="path" rights="none" pattern="@*" /> -->
      
    2. 修改权限为允许读写:
      <policy domain="path" rights="read|write" pattern="@*" />
      
  • 保存并退出编辑器(按Ctrl+O确认保存,回车后按Ctrl+X退出)
  • 重新运行你的Python代码即可。

原因说明

Ubuntu 22.04默认的ImageMagick安全策略比较严格,禁止了通过@符号引用文件的操作,而TextClip生成文本时会通过临时文本文件传递内容,刚好触发了这个限制,调整策略后就能正常执行。

内容的提问来源于stack exchange,提问作者Adhil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 11:37:38