문제

I have a JPEG template:

template image

I need put a JPEG image inside that grey mask and save it as a JPEG. (so resize the jpeg, and put it where the greay mask is).

Is there a way to do that using php and imagemagick extension ?

Regards

도움이 되었습니까?

해결책

If you want your image to be 318px x 235px (to fit in the window of your template), you can resize using ImageMagick:

convert photo-big.jpg -resize '318x235^' photo-small.jpg 

The ^ insures that the small version will not be any smaller than the given dimensions, although one dimension may be bigger, in order to maintain the aspect ratio.

In order to insert the resized image into your template, you'll need a third image to serve as a mask. The mask is only black and white: the white is where you want the photo to show up in your template, like this: mask for template

Use the following line of code to create your composite image. The geometry indicates the offset in pixels (59 down and 15 over) to position the photo in the window:

composite -geometry '+15+59' photo-small.jpg template.jpg mask.jpg comp.jpg
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top