Page 1 of 1
Moving the crop position inside windows in collage
Posted: 2017-08-16T03:10:13-07:00
by feanoro
I have working script which makes a "collage" using convert script:
Code: Select all
convert
( "1.jpg" -resize x2322 -gravity center -crop 1500x2322+0+0 +repage -gravity east -background white -splice 10x0 )
( "2.jpg" -resize x2322 -gravity center -crop 1500x2322+0+0 +repage )
+append -bordercolor white -border 20 result.jpg
The result then looks like this:
https://www.awesomescreenshot.com/image ... 9a1cc88efe
I want to achieve:
- Move individual images inside their collage tiles by X and Y (aka dragging the crop frame around the image in Photoshop).
- Do not change size of the resulting collage (3000x2322 +borders ).
Version: ImageMagick-6.9.2
Any advices? Thank you.
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T05:15:34-07:00
by snibgo
You have "-crop 1500x2322+0+0". Does changing the X and Y components do what you want? Eg "-crop 1500x2322+123+456".
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T05:55:49-07:00
by feanoro
No, it changes the size of the image.
Just take 2 large images and try it yourself with +200+234 and with +0+0. You will see that resulting size changes instead of just cropping the image at given coords
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T06:51:19-07:00
by snibgo
The X and Y offsets specify where the crop should begin. "-crop" doesn't resize. For example, using toes.png:
Code: Select all
convert toes.jpg -crop 100x100+0+0 toes_c1.jpg
Code: Select all
convert toes.jpg -crop 100x100+50+50 toes_c2.jpg
Giving X and Y offsets hasn't resized.
You are doing a crop after a resize. The offsets are in terms of the image after it has been resized.
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T08:07:47-07:00
by feanoro
Can you please post the same method using my code? This doesn't work with resize apparently.
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T08:48:23-07:00
by snibgo
My test image is smaller than yours, so the code is different.
Code: Select all
convert toes.jpg -resize 50% -crop 50x50+0+0 toes_c3.jpg
Code: Select all
convert toes.jpg -resize 50% -crop 50x50+25+25 toes_c4.jpg
(EDIT: I should, of course, "+repage" after cropping. This doesn't affect these simple examples.)
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T15:09:48-07:00
by fmw42
I do not understand what you want to do. If you move the images in your example, they will overlap each other. If that is what you want to do, then create a background image (white) the size you want. Then composite the image in the places you want rather than appending. Something like
Code: Select all
convert -size WxH xc:white \
\( image1 do your resize and crop \) \ -geometry +X1+Y1 -compose over -composite \
\( image2 do your resize and crop \) \ -geometry +X2+Y2 -compose over -composite \
result
Use WxH as your desired output image size. Do your resize and crop as you wrote in your original post. Supply X1 and Y1 for the offsets where you want the first image placed in the background. Do the same for image2 with X2 and Y2.
See
http://www.imagemagick.org/Usage/layers/#convert
If this is not what you want, please clarify. If this is what you want and you need more help, then provide your two input images.
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T15:17:36-07:00
by fmw42
One other option is simply to use +smush -X to move the two images closer or +X to move them further apart horizontally. ( change to -smush to move them up or down). See
http://www.imagemagick.org/script/comma ... .php#smush
Code: Select all
convert logo: rose: -gravity center -background gray +smush +20 logo_rose_smush_p20.jpg
Code: Select all
convert logo: rose: -gravity center -background gray +smush -20 logo_rose_smush_m20.jpg
Change the -gravity and -background as desired.
Afterwards you can use -extent to enlarge the background area with whatever background color you want so that the result has the size you want.
See
http://www.imagemagick.org/Usage/crop/#extent
Re: Moving the crop position inside windows in collage
Posted: 2017-08-16T15:45:30-07:00
by fmw42
If all you want to do is change the crop locations in your code, then in Windows syntax with new lines for easier reading, do
Code: Select all
convert
( "1.jpg" -resize x2322 -gravity center -crop 1500x2322+X1+Y1 +repage ^
-gravity east -background white -splice 10x0 ) ^
( "2.jpg" -resize x2322 -gravity center -crop 1500x2322+X2+Y2 +repage ) ^
+append -bordercolor white -border 20 result.jpg
where X1,Y1 is the pixel offset from the center where you want the crop to take place for 1.jpg and similarly for 2.jpg. Positive values move right and down, negative values move up and left for the crop location. See
http://www.imagemagick.org/Usage/crop/
or as one long line
Code: Select all
convert ( "1.jpg" -resize x2322 -gravity center -crop 1500x232+X1+Y1 +repage -gravity east -background white -splice 10x0 ) ( "2.jpg" -resize x2322 -gravity center -crop 1500x2322+X2+Y2 +repage ) +append -bordercolor white -border 20 result.jpg