AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1519305
Accepted
Madhubala
Madhubala
Asked: 2020-01-23 08:32:46 +0800 CST2020-01-23 08:32:46 +0800 CST 2020-01-23 08:32:46 +0800 CST

ImageMagick:如何添加叠加在图片上的多行文本?文本被截断

  • 772

代码 -

convert -size 2000x1000 xc:none -gravity center \
    -stroke yellow -pointsize 50 -font Courier-BoldOblique -strokewidth 3 -annotate +100+100 caption:'Conflict is the gadfly of thought. It stirs us to observation and memory. It instigates to invention. It shocks us out of sheeplike passivity, and sets us at noting and contriving' \
    -blur 0x25 -level 0%,50% \
    -fill white -stroke none -annotate +100+100 caption:'Conflict is the gadfly of thought. It stirs us to observation and memory. It instigates to invention. It shocks us out of sheeplike passivity, and sets us at noting and contriving' \
    1.jpg  +swap -gravity center -geometry +0-3 \
    -composite  Walpaperquote.jpg

输出 :

Walpaperquote.jpg

我的问题是:我怎样才能使完整的文本出现?哪里出了问题?

提前感谢您的帮助!尝试了很多方法,但无法弄清楚如何正确设置!我对 ImageMagick 很陌生!

bash imagemagick
  • 1 1 个回答
  • 730 Views

1 个回答

  • Voted
  1. Best Answer
    Attie
    2020-01-23T08:46:00+08:002020-01-23T08:46:00+08:00

    这里的解决方案是在输入文本中包含换行符。有几种方法可以做到这一点:

    $'\n'

    使用$'...\n...'- 通过用 引用字符串$'...',启用转义序列 -\n是换行符。有关更多转义序列,请参见此处。

    caption=$'Conflict is the gadfly of thought.\nIt stirs us to observation and memory.\nIt instigates to invention.\nIt shocks us out of sheeplike passivity, and sets us at noting and contriving'
    

    read -d ''

    用于read -d ''从标准输入获取多行 -EOF标记输入的结束。

    read -d '' caption <<EOF
    Conflict is the gadfly of thought.
    It stirs us to observation and memory.
    It instigates to invention.
    It shocks us out of sheeplike passivity, and sets us at noting and contriving
    EOF
    

    多行变量

    实际上可以在引号之间包含换行符,尽管从可读性的角度来看我不喜欢这样。

    caption="Conflict is the gadfly of thought.
    It stirs us to observation and memory.
    It instigates to invention.
    It shocks us out of sheeplike passivity, and sets us at noting and contriving"
    

    用法

    这随后可以用作 的参数convert:

    in_file='1.jpg'
    out_file='Walpaperquote.jpg'
    
    convert -size 2000x1000 xc:none -gravity center \
        -stroke yellow -pointsize 50 -font Courier-BoldOblique -strokewidth 3 -annotate +100+100 "caption:${caption}" \
        -blur 0x25 -level 0%,50% \
        -fill white -stroke none -annotate +100+100 "caption:${caption}" \
        "${in_file}"  +swap -gravity center -geometry +0-3 \
        -composite  "${out_file}"
    

    示例输出(裁剪) - 您仍然需要调整边界框的大小。

    示例输出

    • 1

相关问题

  • 在非 root 用户上用 bash 替换 zsh

  • 在 macOS High Sierra 的终端中设置环境变量时遇到问题

  • 对于 cp 或 mv,是否有等同于 cd - 的东西?

  • Notify-发送窗口下出现的通知

  • 如何从 WSL 打开 office 文件

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve