ImageMagick 无法在 ubuntu 22.04.3 LTS 中工作

问题描述 投票:0回答:1

我已经安装了 ImageMagic 以将文本覆盖在视频剪辑上。但它显示以下错误如何解决这个问题?

使用转录文本创建一个 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:尝试执行安全策略不允许的操作

@/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 二进制文件的路径,或者您指定的路径不正确

python-3.x opencv imagemagick moviepy
1个回答
0
投票

我尝试使用 imagemagick 的转换来尝试将文本打印到图像。我认为这个解决方案也可能适合您,因为它看起来像尝试使用像

@/tmp/tmp8geu2egw.txt
这样的路径,该路径在策略中被阻止。

我在这里找到了一个解决我的问题的例子(见下文): https://github.com/Zulko/moviepy/issues/401#issuecomment-278679961

TLDR 是:

  1. 查找您的策略文件:
    identify -list policy | head
    --> 在命令 shell 中运行此文件;
  2. 编辑策略文件,即注释掉以下行:
<policy domain="path" rights="none" pattern="@*" />

编辑后,它应该如下所示:

  <!-- in order to avoid to get image with password text -->
  <!--<policy domain="path" rights="none" pattern="@*"/> -->

对于渲染文本,按照https://unix.stackexchange.com/questions/138804/how-to-transform-a-text-file-into-a-picture,我尝试过:

convert -size 1500x2500 xc:white -font "Ubuntu-Mono" -pointsize 12 -fill black -annotate +15+15 "@ascii_art.txt" -trim -bordercolor "#FFF" -border 10 +repage image.png
© www.soinside.com 2019 - 2024. All rights reserved.