使用ImageMagick从现有图像生成一堆类似宝丽来的照片
我希望能够拍摄5张JPG图像并使用ImageMagick处理它们以创建一个效果,将照片显示为一堆类似宝丽来的照片。
I would like to be able to take 5 JPG images and process them with ImageMagick to create an effect showing the photos as a stack of Polaroid-like prints.
假设所有照片都具有相同的宽高比,则需要将它们调整为相同尺寸,应用10px宝丽来边框,然后轻微旋转并偏移,使得顶部下方的图像在边缘部分可见。
Assuming all photos are the same aspect ratio, they need to be resized to the same size, a 10px Polaroid-like border applied, then all slightly rotated and offset such that images below the top one are partially visible around the edges.
旋转/偏移不需要是随机的 - 如果它比真正随机的更容易,它可以为堆栈中的每个图像手工编码?
The rotation/offset doesn't need to be random as such - it could be hand-coded for each image in the stack if it is easier than doing it truly random?
以下是我的目标效果示例:
Here is an example of the effect I am aiming for:
有人可以帮助使用正确的参数 - 我假设我们想要使用转换?
Can someone help with the correct parameters to use - I'm assuming we would want to use convert?
编辑:我已经知道ImageMagick页面上包含的示例,但它没有专门解决我的要求 - 他们克隆原始图像,他们不使用多个单独的图像。他们也没有很好地在每个例子中详细解释每个选项的作用 - 他们假设你已经花了几个小时(或几天!)来试验数百万个可用选项。对于从未使用过该工具而没有大量工作的人来说有点困难。
I already knew about the example contained on the ImageMagick page, but it doesn't specifically address my requirements - they clone the original image, they don't use multiple separate images. They also don't do a great job of explaining in each example exactly what every option does - they assume you already have spent hours (or days!) experimenting with the millions of options available. A bit difficult for someone who has never used the tool to master without a lot of work.
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
...如果有人可以扩展这个例子并告诉我如何修改它以达到我想要的结果,那就太棒了。
... it would be great if someone could expand on this example and show me how to modify it to achieve my desired results as above.
这是我发现的命令,可以为我需要的东西提供相当好的结果 - 感谢@Jim Lindstrom让我走上正轨。
Here is the command I found to give a pretty good result for what I needed - thanks to @Jim Lindstrom for putting me on the right track.
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
这是我使用上面的图像得到的输出命令:
Here is the output I get from my images using the above command:
它还不完美,我还有一些我想做的调整whi我将在一个单独的问题中询问。
It's not perfect yet, I have some more tweaks I'd like to do which I'll ask about in a separate question.