2012-04-19 48 views
1

我有兩個圖像。可以是任何尺寸和長寬比。另一個實質上是一個圖案化的圓形PNG蒙版,我想疊加在其他圖像上,調整其他圖像的大小以適應PNG疊加的大小。使用ImageMagick創建固定大小的合成圖像

我的基礎知識與工作:

composite -compose atop -geometry +0+0 -resize 75x73 lib/source/overlay.png #{temp_object.path} #{tempfile.path} 

然而,這並不在源圖像的長寬比不適合覆蓋工作。 ImageMagicks生成的圖像會疊加適合源圖像的圖像。

那麼,我該如何調整這個,以便源圖像被調整大小等,以適應覆蓋和我的合成圖像總是相同的大小,幷包含完整的覆蓋?

圖片示例:

enter image description here enter image description here

回答

4

這是你想要做什麼的一種方式?

convert input.jpg -thumbnail 200x200^ -gravity center -crop 200x200+0+0 mask.png -composite output.jpg 

另一種方法

composite input.jpg -thumbnail 200x200^ mask.png -gravity center -compose screen -matte output.jpg