1

我希望能够拍摄 5 张 JPG 图像并使用 ImageMagick 对其进行处理,以创建一种将照片显示为类似宝丽来的照片的效果。

假设所有照片的纵横比相同,则需要将它们调整为相同大小,应用 10 像素的宝丽来边框,然后全部轻微旋转和偏移,以使顶部下方的图像在边缘部分可见。

旋转/偏移不需要是随机的 - 如果它比真正随机更容易,它可以为堆栈中的每个图像手动编码?

这是我想要达到的效果的一个例子:一堆类似宝丽来的照片

有人可以帮助使用正确的参数吗 - 我假设我们想要使用转换?

编辑:我已经知道 ImageMagick 页面上包含的示例,但它并没有专门满足我的要求 - 他们克隆原始图像,他们不使用多个单独的图像。他们也没有很好地在每个示例中准确解释每个选项的作用 - 他们假设您已经花费数小时(或数天!)试验了数百万个可用选项。对于从未使用过该工具而无需大量工作的人来说,这有点困难。

convert thumbnail.gif \
    -bordercolor white  -border 6 \
    -bordercolor grey60 -border 1 \
    -bordercolor none  -background  none \
    \( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
    \( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
    \( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
    \( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
    -delete 0  -border 100x80  -gravity center \
    -crop 200x160+0+0  +repage  -flatten  -trim +repage \
    -background black \( +clone -shadow 60x4+4+4 \) +swap \
    -background none  -flatten \
    poloroid_stack.png

...如果有人可以扩展此示例并向我展示如何修改它以达到我想要的结果,那就太好了。

4

3 回答 3

5

这是我发现的命令,它可以为我需要的东西提供一个很好的结果——感谢@Jim Lindstrom 让我走上了正确的轨道。

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

这是我使用上述命令从图像中获得的输出:

宝丽来堆栈

它还不完美,我还有一些我想做的调整,我将在一个单独的问题中询问。

于 2013-04-20T11:44:35.803 回答
2

“转换”的文档几乎完全显示了如何。在http://www.imagemagick.org/Usage/thumbnails/#polaroid上搜索“好看的一堆照片”

这是另一种方法,希望可以更清楚地说明如何在自己的照片中添加内容:

# create four images we want to use as our polaroid stack (I'm using the same one for all
# one, but you don't have to)
curl -O http://www.imagemagick.org/Usage/thumbnails/thumbnail.gif
cp thumbnail.gif thumbnail1.gif
cp thumbnail.gif thumbnail2.gif
cp thumbnail.gif thumbnail3.gif
cp thumbnail.gif thumbnail4.gif
rm thumbnail.gif

# You can easily see the recurring portion of this command. You could build 
# it up programmatically and then execute it, for however many images you want.
# I've also simplified the example in their docs by hard-coding some rotation
# angles. Feel free to get fancy, or just hard code an array of them and keep
# grabbing the next one.
convert \
   thumbnail1.gif \
   -bordercolor white  -border 6 \
   -bordercolor grey60 -border 1 \
   -bordercolor none  -background  none \
   -rotate 20  \
   -trim +repage \
   \
   \( \
   thumbnail2.gif \
   -bordercolor white  -border 6 \
   -bordercolor grey60 -border 1 \
   -bordercolor none  -background  none \
   -rotate -8 \
   -trim +repage \
   \) \
   -gravity center \
   -composite \
   \
   \( \
   thumbnail3.gif \
   -bordercolor white  -border 6 \
   -bordercolor grey60 -border 1 \
   -bordercolor none  -background  none \
   -rotate 3 \
   -trim +repage \
   \) \
   -gravity center \
   -composite \
   \
   \( \
   thumbnail4.gif \
   -bordercolor white  -border 6 \
   -bordercolor grey60 -border 1 \
   -bordercolor none  -background  none \
   -rotate -17 \
   -trim +repage \
   \) \
   -gravity center \
   -composite \
   \
   -crop 200x160+0+0  +repage  -flatten  -trim +repage \
   -background black \( +clone -shadow 60x4+4+4 \) +swap \
   -background none  -flatten \
   \
   poloroid_stack.png
于 2013-04-19T15:30:07.703 回答
1

我使用 Simpon Hampel 代码,对此进行了一些更改:

如何在imagemagick中使用阴影边缘图像?

请检查一下..

于 2014-10-13T19:58:28.457 回答