使用 ImageMagick 创建的偏移堆叠图像
Posted
技术标签:
【中文标题】使用 ImageMagick 创建的偏移堆叠图像【英文标题】:Offset stacked images created using ImageMagick 【发布时间】:2013-04-20 12:02:51 【问题描述】:我目前正在使用以下 ImageMagick 命令从多张 JPG 图像中创建照片的“宝丽来堆栈”。
convert \
img-5.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate -4 \
\
\( img-2.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate 6 \
\) \
\
\( img-3.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate -2 \
\) \
\
\( img-1.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate -4 \
\) \
\
\( img-4.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate 4 \
\) \
\
-border 100x80 -gravity center +repage -flatten -trim +repage \
-background black \( +clone -shadow 60x4+4+4 \) +swap -background none \
-flatten stack.png
此命令生成以下图像:
我想做的是将图像从旋转选项当前使用的中心轴偏移开,以便照片之间有更多的水平(可能还有一点垂直)分离。
更具体地说,我希望能够通过左右移动(也许上下移动一点)来看到更多显示在最顶部图像边缘周围的底层图像.
我可以在上面的转换调用中添加哪些命令来实现这一点?
【问题讨论】:
【参考方案1】:-repage geometry
Adjust the canvas and offset information of the image.
这是来自 imagemagick.org http://www.imagemagick.org/Usage/layers/#layer_prog 的一个很好的例子
【讨论】:
谢谢 - 这正是我所需要的。我发现我必须对原始命令进行一些其他调整才能使其正常工作。【参考方案2】:感谢@Iamiuru 让我走上正轨。不幸的是,仅靠 -repage 是不够的,我必须在其他地方进行一些调整才能使其正常工作。
这是我最终使用的命令:
convert \
img-5.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate 3 -repage -20-5 \
\
\( img-2.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate -5 -repage -10+0 \
\) \
\
\( img-3.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate 4 -repage -30+10 \
\) \
\
\( img-1.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate -4 -repage +20-10 \
\) \
\
\( img-4.jpg -thumbnail 300x200 -bordercolor white -border 10 \
-bordercolor grey60 -border 1 -bordercolor none \
-background none -rotate 2 \
\) \
\
-border 100x80 -flatten -trim +repage -background black \
\( +clone -shadow 60x4+4+4 \) +swap -background none -flatten stack.png
从我的原始命令中,我必须删除 -gravity center +repage
选项,因为这些选项只是将所有图像重新居中到其原始位置,并且 -repage 不起作用。
此命令生成以下图像:
【讨论】:
以上是关于使用 ImageMagick 创建的偏移堆叠图像的主要内容,如果未能解决你的问题,请参考以下文章