[英]ImageMagick montage natural file order
I am trying to use the ImageMagick montage feature to combine chunks of maps from a game. 我正在尝试使用ImageMagick蒙太奇功能来组合游戏中的大块地图。 My issue is that the game's original files are naturally ordered like
我的问题是,游戏的原始文件自然会像
part1.png part2.png ... part10.png part1.png part2.png ... part10.png
ImageMagick reads this and will tile part10.png after part1.png. ImageMagick读取此内容,并将在part1.png之后平铺part10.png。 Is there a flag/option to tell IM to read the directory the way I want it to?
是否有标记/选项告诉IM以我想要的方式读取目录? This is a live code sample of what I'm doing.
这是我正在做的实时代码示例。
montage \
-alpha on \
-background none \
-mode concatenate \
-tile x{$grid} \
-mattecolor none \
{$input_dir}/*.png \
{$output_file}
You can possibly use sort -g
(that's general numeric sort ) to get what you want. 您可能可以使用
sort -g
(这是常规的数字sort )来获取所需的内容。
Test: 测试:
Create 12 dummy files: 创建12个虚拟文件:
for i in {1.12} ; do touch ${i}.txt ; done
List the files: 列出文件:
ls -1 *.txt
1.txt
10.txt
11.txt
12.txt
2.txt
3.txt
4.txt
5.txt
6.txt
7.txt
8.txt
9.txt
Use sort -g
to list them in different order: 使用
sort -g
以不同的顺序列出它们:
ls -1 *.txt | sort -g
1.txt
2.txt
3.txt
4.txt
5.txt
6.txt
7.txt
8.txt
9.txt
10.txt
11.txt
12.txt
Real Life: 现实生活:
Now apply this to solve your problem: 现在应用此解决您的问题:
montage \
-alpha on \
-background none \
-mode concatenate \
-tile x{$grid} \
-mattecolor none \
$(ls -1 {$input_dir}/*.png | sort -g) \
{$output_file}
If your $input_dir
name doesn't contain any spaces, this should work flawlessly. 如果您的
$input_dir
名称不包含任何空格,则应该可以正常使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.