Linux 下有没有很方便的图片拼接软件?

2025 年 5 月 11 日
 wencan
比如,将四张图拼成 2x2 的组合图
或者 3 张图,右边一张,左边上下各一张
目前每次都是上传到 canva.cn 去拼,拼图很强大,但就是还要上传

最好还支持抠图,生成白底图、透明图
3465 次点击
所在节点    Linux
14 条回复
usVexMownCzar
2025 年 5 月 11 日
GIMP
senooo
2025 年 5 月 11 日
Python 大法好
magzza
2025 年 5 月 11 日
ImageMagick 应该可以的
MossFox
2025 年 5 月 11 日
浏览器按理说纯本地环境也是支持这类基础图片处理的,在线工具上传图片处理属于弱化了不少客户端本来就有的能力,

透明转白底可以直接 Canvas 一比一填个底色然后画 img ,
基础的拼图可以手动框区域填充,也是 Canvas 那套,
抠图可以用 https://github.com/imgly/background-removal-js 或者同类型的工具(纯本地),不过注意这个只擅长照片类型,不擅长插图类型的素材,
某些时候如果想要转矢量,也可以用这个 https://github.com/visioncortex/vtracer
图片处理如果有浏览器不支持的类型 (AV1, JPEG XL 之类),可以用 https://github.com/kleisauke/wasm-vips 在浏览器里面本地转换。

这些是基建啦。如果想合在一起弄一个浏览器里跑的本地工具,会前端的可以搓一个,不熟练的但是表达能力还行的可以让大模型造一个。如果是比较常见的需求,搞不好哪里已经有人造好了但是没做过宣传的工具。
openmynet
2025 年 5 月 11 日
https://github.com/theotherphil/imagecli 需要你自己编译到 Linux 版本,再配合 python 很容易满足你的要求
```python
import os
import subprocess
import argparse
from PIL import Image
import re

if __name__ == "__main__":

# python jpeg_hcat.py title a.jpg b.jpg c.jpg --p="hcat"

# 接收所有输入的参数并打印
# print(sys.argv[1:])

# 创建 ArgumentParser 对象
parser = argparse.ArgumentParser(description="示例程序")

# 添加 --type 参数
parser.add_argument(
"--type",
type=str,
default="hcat",
choices=["hcat", "vcat", "grid"],
help="操作类型",
)
# 添加 --cols 参数
parser.add_argument(
"--cols",
type=int,
default=3,
help="列数",
)
# 添加 --name 参数
parser.add_argument(
"--name",
type=str,
default="image",
help="输出文件名",
)
# 添加 --cols 参数
parser.add_argument(
"--author",
type=str,
default="",
help="输出作者",
)
parser.add_argument("files", nargs="+", type=str, help="输入的文件列表")
# 解析命令行参数
args = parser.parse_args()
process = args.type
files = []
name = args.name

# 接收所有输入的参数并检查参数是否包含文件
for file in args.files:
# 检查文件是否存在
temp = file.lower()
if os.path.exists(file) and os.path.isfile(file):
if temp.endswith(".jpg") or temp.endswith(".jpeg") or temp.endswith(".png"):
# 将文件名转为小写后判断
files.append(file)

# 文件数量
file_len = len(files)

if file_len == 0:
print("没有文件")
exit(0)
renames = []
image = Image.open(files[0])
width, height = image.size
rows = file_len
if process == "grid":
if rows < args.cols:
process = "hcat"
else:
# 计算行数
rows_sqrt = int(rows**0.5)
cols = rows_sqrt
if rows_sqrt > 5:
cols = 5
rows = file_len // 5
else:
cols = rows_sqrt
rows = rows_sqrt
if cols * rows < file_len:
for i in [4, 3, 2]:
n = file_len // i
if n * i == file_len:
rows = n
cols = i
break
process = f"grid {cols}"
pattern = r"(\d)x(\d)"
matrix = re.findall(pattern, args.author)
if matrix and len(matrix) == 1:
cols = int(matrix[0][0])
rows = int(matrix[0][1])
miss = cols * rows - file_len
if miss > 0:
# 补齐
id = ", ".join(["id"] * file_len)
process = f"[{id}, (new {width} {height} (255, 255, 255) > DUP {miss-1})] > grid {cols}"

# 获取文件拓展名
ext = os.path.splitext(files[0])[1]

# 使用第一文件路径作为输出文件路径,并使用 name 作为文件名
name = name + ext
output = os.path.join(os.path.dirname(files[0]), name)
target = f'"{output}"'
# 将 files 格式化为字符串,以空格分隔,使用引号将文件名括起来
quoted_files = ['"{}"'.format(file) for file in files]
input = " ".join(quoted_files)

# 运行命令
cmd = f'imagecli.exe -i {input} -o {target} -p "{process} {rows}"'
# os.system(cmd)
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
# 打开图片
# 1. 检查图片是否存在
if os.path.exists(output):
# 2. 打开图片
os.startfile(output)

# 接收所有输入的参数并保存到指定文件中
out = "D:\Program Files\clawPDF\scripts\log.txt"
with open(out, "w") as f:
f.write(cmd + "\n")

```
zuotun
2025 年 5 月 11 日
CLI FFMpeg
GUI GIMP
printese
2025 年 5 月 11 日
ImageMagick 下的 montage 工具貌似可以部分满足需求
MrKrabs
2025 年 5 月 12 日
不如手机
henix
2025 年 5 月 12 日
拼接用 ImageMagick 命令行 montage 工具
抠图用 GIMP 相似像素选择,跟 PS 类似,要手动操作一下
huangmingyou
2025 年 5 月 12 日
imagemagick , 下面是我用来生成一个 2k+4k 组合屏幕壁纸的命令。
#!/bin/bash
# need 2560.png and 3840.png
convert -size 6400x2160 xc:black black.png
convert black.png \( 2560.png -resize 2560x1440 \) -geometry +0+0 -composite result_temp.png
convert result_temp.png \( 3840.png -resize 3840x2160 \) -geometry +2560+0 -composite final_result.png
CFM880
2025 年 5 月 12 日
figma linux
xy2401
2025 年 5 月 12 日
Tomatopotato
2025 年 5 月 13 日
有一说一 你传到手机上用手机拼一下再传回电脑都比在 linux 上折腾来得快。
d4eorg
2025 年 5 月 23 日
GraphicsMagick/ImageMagick

gm convert "$file1" "$file2" +append -quality 90 "$output"

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1131008

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX