使用ImageMagick从现有图像生成一堆类似宝丽来的照片

使用ImageMagick从现有图像生成一堆类似宝丽来的照片,imagemagick,Imagemagick,我想能够采取5 JPG图像,并处理他们与ImageMagick创建一个效果显示为一个像宝丽来打印堆叠的照片 假设所有照片都具有相同的纵横比,则需要将它们调整为相同的大小,应用一个10px的宝丽来样边框,然后稍微旋转并偏移,以便顶部下方的图像在边缘周围部分可见 旋转/偏移本身不需要是随机的-如果它比真正随机更容易,那么可以为堆栈中的每个图像手动编码 以下是我希望达到的效果的一个例子: 有人能帮助我们使用正确的参数吗?我想我们应该使用convert 编辑:我已经知道ImageMagick页面上包含的

我想能够采取5 JPG图像,并处理他们与ImageMagick创建一个效果显示为一个像宝丽来打印堆叠的照片

假设所有照片都具有相同的纵横比,则需要将它们调整为相同的大小,应用一个10px的宝丽来样边框,然后稍微旋转并偏移,以便顶部下方的图像在边缘周围部分可见

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

以下是我希望达到的效果的一个例子:

有人能帮助我们使用正确的参数吗?我想我们应该使用convert

编辑:我已经知道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

。。。如果有人能对这个例子进行扩展,并向我展示如何修改它,以达到上述我想要的结果,那就太好了。

convert的文档几乎准确地展示了如何修改它。在上搜索一堆好看的照片

下面是另一种方法,希望能让人们更清楚地了解如何在自己的照片中使用sub:

# 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的文档几乎完全显示了如何转换。在上搜索一堆好看的照片

下面是另一种方法,希望能让人们更清楚地了解如何在自己的照片中使用sub:

# 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

这是我发现的一个命令,它为我所需要的提供了一个非常好的结果——感谢@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
以下是我使用上述命令从图像中获得的输出:


它还不完美,我想做更多的调整,我将在另一个问题中询问。

这是我找到的命令,可以为我所需要的提供非常好的结果-感谢@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
以下是我使用上述命令从图像中获得的输出:


它还不完美,我想做更多的调整,我将在另一个问题中询问。

我使用Simpon-Hampel代码,在这方面做了一些更改:


请检查..

我使用Simpon-Hampel代码,但有一些改动:


请检查一下。

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