Page 1 of 1

Composite with resize & gravity center in one line

Posted: 2017-07-23T01:57:52-07:00
by makz
Hello

I'm trying to resize/crop images and composite them in a larger to make triple screens wallpaper.

So at first i use

Code: Select all

convert 1.jpg -resize 1920x1080^ -gravity center -extent 1920x1080 1-resize.jpg
for all my images and i composite them after with

Code: Select all

convert -size 5760x1080 xc:white 1-resize.jpg -geometry +0+0 -composite 2-resize.jpg -geometry +1920+0 -composite 3-resize.jpg -geometry +3840+0 -composite triple.jpg
But i'm wondering if i could do that in one command

i end up with this command

Code: Select all

convert -size 5760x1080 xc:white 1.jpg -geometry 1920x1080^+0+0 -composite 2.jpg -geometry 1920x1080^+1920+0 -composite 3.jpg -geometry 1920x1080^+3840+0 -composite triple.jpg
but my images are not verticaly centered.
If i add -gravity center it center my whole canvas so my first wallpaper is on the second screen, the second on the third screen and the third wallpaper is invisible because the canvas is moved 1920px to the right

Is this kind of job is possible in a single command ?

Thank you.

Re: Composite with resize & gravity center in one line

Posted: 2017-07-23T06:32:19-07:00
by GeeMack
makz wrote: 2017-07-23T01:57:52-07:00I'm trying to resize/crop images and composite them in a larger to make triple screens wallpaper. [...] Is this kind of job is possible in a single command ?
Try something like this...

Code: Select all

convert img1.jpg img2.jpg img3.jpg -resize 1920x1080^ -gravity center -extent 1920x1080 +append triple.jpg
That reads in all three images, resizes them, crops them with "-extent", then simply attaches one to the other left to right with "+append".

Re: Composite with resize & gravity center in one line

Posted: 2017-07-23T09:11:24-07:00
by makz
This command do the job if i have 3 1920x1080 screens on the same y position but depending on the setup, some image may have different resolutions and position than another one, so i really need to set the position & resolution per images and not a global resolution.

Re: Composite with resize & gravity center in one line

Posted: 2017-07-23T09:36:42-07:00
by GeeMack
makz wrote: 2017-07-23T09:11:24-07:00This command do the job if i have 3 1920x1080 screens on the same y position but depending on the setup, some image may have different resolutions and position than another one, so i really need to set the position & resolution per images and not a global resolution.
For each image you can set the paging information separately by doing a "-repage" on each inside their own parentheses. That sets the canvas size and location for each image. Then you can "-flatten" all three images to create a finished canvas with each image in your chosen location. Something like this should work...

Code: Select all

convert img1.jpg img2.jpg img3.jpg -resize 1920x1080^ -gravity center -extent 1920x1080 \
   \( -clone 0 -repage 5760x1080+0+0 \) \( -clone 1 -repage 5760x1080+1920+0 \) \
   \( -clone 2 -repage 5760x1080+3840+0 \) -delete 0,1,2 -flatten triple.jpg

Re: Composite with resize & gravity center in one line

Posted: 2017-07-23T11:18:43-07:00
by makz
Thank you but even with this command it's okay if i have 3 1920x1080 screens but not if i have different screen resolution.

For exemple i have Left = 1920x1080 screen in normal position, Center = 640x480 screen lower than other screens and Right = 1920x1080 at the same level as my left screen.

On a 4480x1280 canvas my wallpapers are placed in the same geometry as my screens :

1920x1080+0+0
640x480+1920+800
1920x1080+2560+0

it should make something like that

Image