【问题标题】:Generate a stack of Polaroid-like photos from existing images using ImageMagick使用 ImageMagick 从现有图像生成一堆类似宝丽来的照片
【发布时间】:2013-04-12 19:42:42
【问题描述】:

我希望能够拍摄 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

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

【问题讨论】:

    标签: imagemagick


    【解决方案1】:

    这是我发现的命令,它可以为我需要的东西提供一个很好的结果 - 感谢 @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
    

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

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

    【讨论】:

      【解决方案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
      

      【讨论】:

      • 实际上,他们没有。他们没有给出如何使用多个不同图像的具体示例——他们克隆了原始图像。他们也没有很好地解释每个选项在他们的示例中的作用——这使得从未使用过 convert 的人在不花费数小时进行试验的情况下很难弄清楚到底发生了什么。如果你能以他们的例子并对其进行扩展以满足我上面指定的需求,这将非常有帮助,解释这些选项的作用,以便我可以根据我的需要进行调整。
      • 感谢@Jim Lindstrom - 您的解决方案并没有完全满足我的需求,但它确实让我走上了正轨。
      【解决方案3】:

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

      How Margin Image with shadow in imagemagick?

      请检查一下..

      【讨论】:

        猜你喜欢
        • 2011-05-31
        • 1970-01-01
        • 2016-12-20
        • 2017-03-29
        • 2020-11-12
        • 1970-01-01
        • 2015-01-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多