使用 ImageMagick 重复或“平铺”一个图像

发布于 2024-12-16 22:11:46 字数 280 浏览 4 评论 0原文

如何使用 ImageMagick 平铺图像?我认为我不能使用 montage 因为我希望列移位原始图像高度的 50%。

展示我想要做的事情的示例可能更容易:

开头:

在此处输入图像描述

结尾:

在此处输入图像描述

谢谢!

How do I tile an image using ImageMagick? I don't think I can use montage because I want the columns displaced by 50% of the original image height.

It's probably easier to show an example of what I'm trying to do:

Start with:

enter image description here

End with:

enter image description here

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

仅一夜美梦 2024-12-23 22:11:46

如果您想要普通瓷砖,而不需要向下移动第二列和其余偶数列,您可以使用以下脚本:(

convert -size 800x600 tile:Ball.jpg Tiles.jpg

可能大多数登陆这个问题的人都想要这样的普通瓷砖,就像我一样)

我的“Ball. “jpg”的大小为 200 x 200 像素,因此此脚本创建一个 4x3 平铺图像。

对于 ImageMagick 7 用户,请将 Convert 替换为 magick。

In case you want plain tiles, without shifting down the second column and the rest of the even columns, you can use this script:

convert -size 800x600 tile:Ball.jpg Tiles.jpg

(probably the majority of people landing on this question want such plain tiles, like I did)

My "Ball.jpg" is 200 x 200 pixels, so this script creates a 4x3 tile image.

For ImageMagick 7 users, replace convert with magick.

无尽的现实 2024-12-23 22:11:46

感谢 Fred 的 ImageMagick 脚本 上的 Fred,这是解决方案:

infile="tile.png"

h2=`convert $infile -format "%[fx:round(h/2)]" info:`

convert $infile \( -clone 0 -roll +0+$h2 \) +append -write mpr:sometile +delete -size 1000x500 tile:mpr:sometile output.png

这正是我正在寻找的为了。

Thanks to Fred at Fred's ImageMagick Scripts, here's the solution:

infile="tile.png"

h2=`convert $infile -format "%[fx:round(h/2)]" info:`

convert $infile \( -clone 0 -roll +0+$h2 \) +append -write mpr:sometile +delete -size 1000x500 tile:mpr:sometile output.png

This is exactly what I was looking for.

最好是你 2024-12-23 22:11:46

即使您没有提及任何有关使用上下文的内容,我也会将其放在这里以便更多人知道。 Fred 的脚本仅供非商业使用。我以替代解决方案结束,但是原理是相同的:

  1. 创建移动图块:

    转换_orange_270.jpg -roll +0+135 _orange_270_r.jpg

  2. 创建一列常规图块:

    蒙太奇_orange_270.jpg +克隆 +克隆 +克隆 -tile x4 -geometry +0+0 _1col.jpg

  3. 创建一列移位图块:

    蒙太奇_orange_270_r.jpg +克隆 +克隆 +克隆 -tile x4 -geometry +0+0 _2col.jpg

  4. 组合常规列和移位列:

    蒙太奇-几何+0+0 _1col.jpg _2col.jpg _2cols.jpg

  5. 使用第 4 点的最后输出创建完整平铺图像:

    转换_2cols.jpg -写入mpr:tile +删除-大小1920x1080tile:mpr:tile _wallpap.jpg

结果:

在此处输入图像描述

Even though you did not mention anything about context of usage, I will put it here so more people are aware. Fred's scripts are for non-commercial use. I ended with an alternative solution, however, principle is the same:

  1. Creating shifted tile by:

    convert _orange_270.jpg -roll +0+135 _orange_270_r.jpg

  2. Create a column of regular tiles:

    montage _orange_270.jpg +clone +clone +clone -tile x4 -geometry +0+0 _1col.jpg

  3. Create a column of shifted tiles:

    montage _orange_270_r.jpg +clone +clone +clone -tile x4 -geometry +0+0 _2col.jpg

  4. Combined regular and shifted columns:

    montage -geometry +0+0 _1col.jpg _2col.jpg _2cols.jpg

  5. Created full tiled image using last output from point 4:

    convert _2cols.jpg -write mpr:tile +delete -size 1920x1080 tile:mpr:tile _wallpap.jpg

Result:

enter image description here

呆头 2024-12-23 22:11:46

如果在带有 ImageMagick 的类 UNIX 系统上,您可以使用我的脚本,tileimage,位于 http ://www.fmwconcepts.com/imagemagick/tileimage/index.php

它提供了多种翻转、旋转和偏移的变化。

如果非商业用途,那么它是免费的,如果商业用途,那么联系我获取许可证。

有关 ImageMagick 中平铺的信息,请访问 http://www.imagemagick.org/Usage/canvas /#图块

If on a unix-like system with ImageMagick, you could just use my script, tileimage at http://www.fmwconcepts.com/imagemagick/tileimage/index.php.

It provides numerous variations on the flipping, rotation and offsets.

If non-commercial use, then it is free, If commercial use, then contact me for a license.

Information about tiling in ImageMagick can found at http://www.imagemagick.org/Usage/canvas/#tile

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文