bash - In Terminal - For-loop 将每张连续的 18 张图片拼接成一张图片
问题描述
我有一个小脚本,可以下载大图片的一部分,然后尝试将它们拼接在一起。
例如,我有 234 张小图片,它们合起来就构成了一张大全景图。如何编写我的脚本(在 macOS 上的 zsh 中),以便它垂直附加一组连续的 18 张图片(即图片 1..18,然后是 19..36 等),然后缝合所有生成的 12 个垂直条图片一起到最终输出?
这将是我脚本的相关部分。此时变量y
将包含数字 234,即下载的图片总量。
#!/bin/bash
((y = 234))
((h = 1)) # set up the counter
for (( z = 1; z <= $y; z+=1 )); do # the for-loop should start with the first picture, going until the maximum amount (here 234) and iterate by one
convert -append $(ls $z.jpg | sort -V) $h-x.jpg # here the script shall combine vertically 18 pictures to one picture set called 1-x.jpg, subsequently 2-x.jpg, 3-x.jpg etc.
((z % 18 != 0)) # after every 18th picture it shall increment the counter
((h = h + 1))
done
convert +append $(ls $h-* | sort -V) final.jpg # finally the script shall take all 12 pictures vertically congregated to one final picture by appending them horizontally together
目前的脚本什么都不做,没有拼接,也没有给我任何错误信息。
我的代码有什么问题?
解决方案
推荐阅读
- labview - LabVIEW - 如何在for循环中每次迭代后清除数组
- cross-domain - Tampermonkey 是否可以在不同的网站上共享一个存储空间?
- spring-integration-sftp - 忽略或接受文件的最佳实践 - SftpInboundFileSynchronizer 或 MessageHandler
- javascript - 我有一个记事本,每个笔记都有一个标题和主要内容。单击标题时如何使内容出现/消失?
- sql - 使用 Cpanel 连接到 MSSQL 服务器
- lando - 有没有类似于lando中的docker exec的命令?
- android - 深度链接在 Android 中不起作用。因为我不想使用覆盖方法,我的以下代码看起来像
- git - Visual Studio 2019 16.10.3 中的 Git Diff Tool 设置不起作用
- c# - C# 的 PluralizationService 中是否存在错误,或者我没有正确设置某些内容?
- c++ - 从 QThread 发出的信号从未收到