Montage: files with different dimension, but right proportions
Montage: files with different dimension, but right proportions
Hello,
i've a 'ghetto' IM PHP PicM0nkey tool published on my intranet. It does its job well and simple.
I implemented mosaic tool in these days, and obtain some good result:
Now I need IM magic to avoid too PHP coding. My 'web' tool cut uploaded images in proportion to fit white rectangles you see above.
In proportion, because i don't want to touch uploaded user images. So i obtain, for this example, five images.
http://gazzettannunci.gazzettadimantova ... frm/01.png
http://gazzettannunci.gazzettadimantova ... frm/02.png
http://gazzettannunci.gazzettadimantova ... frm/03.png
http://gazzettannunci.gazzettadimantova ... frm/04.png
http://gazzettannunci.gazzettadimantova ... frm/05.png
How Montage them and obtain this result using IM ?
(Windows ImageMagick 6.9.1-10 Q16 x86 2015-07-25 version)
http://gazzettannunci.gazzettadimantova ... ontage.jpg
thank you for all magic,
m.
i've a 'ghetto' IM PHP PicM0nkey tool published on my intranet. It does its job well and simple.
I implemented mosaic tool in these days, and obtain some good result:
Now I need IM magic to avoid too PHP coding. My 'web' tool cut uploaded images in proportion to fit white rectangles you see above.
In proportion, because i don't want to touch uploaded user images. So i obtain, for this example, five images.
http://gazzettannunci.gazzettadimantova ... frm/01.png
http://gazzettannunci.gazzettadimantova ... frm/02.png
http://gazzettannunci.gazzettadimantova ... frm/03.png
http://gazzettannunci.gazzettadimantova ... frm/04.png
http://gazzettannunci.gazzettadimantova ... frm/05.png
How Montage them and obtain this result using IM ?
(Windows ImageMagick 6.9.1-10 Q16 x86 2015-07-25 version)
http://gazzettannunci.gazzettadimantova ... ontage.jpg
thank you for all magic,
m.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage: files with different dimension, but right proportions
Montage cannot do that.
Use -append to stack images 4 and 5. Use -append to stack images 2 and 3. Then use +append to place image1, image2-3, image4-5 side-by-side
If you image are too big or not the right dimensions, then you will need to resize and/or crop them to make them fit. This can be done within each parenthesis for each image
Use -append to stack images 4 and 5. Use -append to stack images 2 and 3. Then use +append to place image1, image2-3, image4-5 side-by-side
Code: Select all
convert 01.png \( 02.png 03.png -append \) \( 04.png 05.png -append \) +append result.png
Code: Select all
convert \
\( 01.png -resize ... -crop ... +repage \) \
\( 02.png -resize ... -crop ... +repage \) \( 03.png -resize ... -crop ... +repage \) -append \) \
\( 04.png -resize ... -crop ... +repage \) \( 05.png -resize ... -crop ... +repage \) -append \) \
+append result.png
Re: Montage: files with different dimension, but right proportions
Thank you for reply fmw,
i think different approach. I cannot known upload image size (HxW).
So I choose to crop, via web, the right 'slice', in proportion.
(eg:01.png posted is in the right proportion to fit exactly in first rectangle)
My web tool always return 5 'puzzle card', that may fit each other, except for their size.
I think to create a canvas with fixed width and height
(eg: for above example 2000 x 3000 pixel)
Then resize each 'puzzle card' to reach 'reserved' place width and height. (small pieces will be enlarged, large ones shrinked). Then
Can be a different, but also valid, way to face up this task ?
thank you for reading,
m.
i think different approach. I cannot known upload image size (HxW).
So I choose to crop, via web, the right 'slice', in proportion.
(eg:01.png posted is in the right proportion to fit exactly in first rectangle)
My web tool always return 5 'puzzle card', that may fit each other, except for their size.
I think to create a canvas with fixed width and height
(eg: for above example 2000 x 3000 pixel)
Then resize each 'puzzle card' to reach 'reserved' place width and height. (small pieces will be enlarged, large ones shrinked). Then
Code: Select all
convert 01.png \( 02.png 03.png -append \) \( 04.png 05.png -append \) +append result.png
thank you for reading,
m.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage: files with different dimension, but right proportions
If you know the size you want to resize for each image, then just include that as per my command above. You can choose to crop or pad if you use -resize and -background and -extent in each parenthesis as I mentioned above. You do not need to know the input sizes, if you know the sizes that you want for each section.
If the images are already the proper aspect ratios, then just append them as in my original command and then resize the result to the final size you want.
If the images are already the proper aspect ratios, then just append them as in my original command and then resize the result to the final size you want.
Re: Montage: files with different dimension, but right proportions
Hello,
made some test with raw code :
On this server we have an old IM installation so Windows/dos syntax is only way to obtain my final goal.
Can you optimize above spartan script, and speed-up things if possible ?
How remove white on bottom image ?
(i think this is due to the fact that the PHP calculations are a bit approximate)
Thank you for all support,
m.
made some test with raw code :
Code: Select all
convert 01.png -resize 1000 01_res.png
convert 02.png -resize 1000 02_res.png
convert 03.png -resize 1000 03_res.png
convert 04.png -resize 1000 04_res.png
convert 05.png -resize 1000 05_res.png
convert 02_res.png 03_res.png -append result23.png
convert 04_res.png 05_res.png -append result45.png
convert result23.png result45.png +append resultd2345.png
convert 01_res.png resultd2345.png +append -resize 1000 -quality 75 result123456.jpg
Can you optimize above spartan script, and speed-up things if possible ?
How remove white on bottom image ?
(i think this is due to the fact that the PHP calculations are a bit approximate)
Thank you for all support,
m.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage: files with different dimension, but right proportions
Code: Select all
convert 01.png 02.png 03.png 04.png 05.png -resize 1000 ^
( -clone 1,2 -append ) ^
( -clone 3,4 -append ) ^
-delete 1-4 +append -resize 1000 -quality 75 result123456.jp
or
Code: Select all
convert 01.png 02.png 03.png 04.png 05.png -resize 1000 ^
( -clone 1,2 -append ) -delete 1,2 ^
( -clone 1,2 -append ) -delete 1,2 ^
+append -resize 1000 -quality 75 result123456.jp
Re: Montage: files with different dimension, but right proportions
Thank you,
return an error, but maybe Windows bin are too old ? !
m.
return an error, but maybe Windows bin are too old ? !
Code: Select all
convert.exe: UnrecognizedOption `-append)' @ error/convert.c/ConvertImageComman
d/739.
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Montage: files with different dimension, but right proportions
Make sure you leave a space after "-append" and before the parentheses ")" like this...myspacee wrote: ↑2017-12-04T14:57:13-07:00Thank you,
return an error, but maybe Windows bin are too old ? !
Code: Select all
convert.exe: UnrecognizedOption `-append)' @ error/convert.c/ConvertImageComman d/739.
Code: Select all
... ( -clone 1,2 -append ) ...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage: files with different dimension, but right proportions
I made a mistake. There needs to be spaces between text and parentheses. I have corrected that. Thanks GeeMack for catching that.
Re: Montage: files with different dimension, but right proportions
Hello,
take some time to learn how assemble some models, but users are happy.
Another request, how spacing images using fmw42 syntax ?
Try to add:
but I want to border all images and then assemble together
Thank you for any help
m.
take some time to learn how assemble some models, but users are happy.
Another request, how spacing images using fmw42 syntax ?
Try to add:
Code: Select all
-bordercolor "#ffffff" -border 6
Thank you for any help
m.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage: files with different dimension, but right proportions
Code: Select all
convert 01.png 02.png 03.png 04.png 05.png -resize 1000 -bordercolor white -border 6 ^
( -clone 1,2 -append ) ^
( -clone 3,4 -append ) ^
-delete 1-4 +append -resize 1000 -quality 75 result123456.jp
Re: Montage: files with different dimension, but right proportions
Thank you again, Picmonk3y trembles
Re: Montage: files with different dimension, but right proportions
Hello again,
try another model but hit my face with my IM limit...
Try to assemble images horizontally :
to obtain this :
And obtain :
Images are in proportion as usual, i think that : horizontally messed up things.
Post my original images there :
http://gazzettannunci.gazzettadimantova ... ert/01.png
http://gazzettannunci.gazzettadimantova ... ert/02.png
http://gazzettannunci.gazzettadimantova ... ert/03.png
http://gazzettannunci.gazzettadimantova ... ert/04.png
if you want help me to learn something new.
Thank you and sorry for questions,
m.
try another model but hit my face with my IM limit...
Try to assemble images horizontally :
Code: Select all
convert 01.png 02.png 03.png 04.png -resize 1000 -bordercolor white -border 12 ( -clone 0,1 +append ) -delete 0,1 ( -clone 0,1 +append ) -delete 0,1 -append -resize 1000 -quality 75 1234.png
And obtain :
Images are in proportion as usual, i think that :
Code: Select all
-resize 1000
Post my original images there :
http://gazzettannunci.gazzettadimantova ... ert/01.png
http://gazzettannunci.gazzettadimantova ... ert/02.png
http://gazzettannunci.gazzettadimantova ... ert/03.png
http://gazzettannunci.gazzettadimantova ... ert/04.png
if you want help me to learn something new.
Thank you and sorry for questions,
m.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage: files with different dimension, but right proportions
Images 1 and 2 do not have the same height, so +append will add white space to make them both the same height. Similarly for 3 and 4. Thus your images are not the right proportions to append the way you want. You may want to resize the image to have the same heights. With imagemagick 6, you will have to determine the dimension with by preprocessing to figure them out. With imagemagick 7, you can do that inline with -set option:
Try this (unix syntax):
Try this (unix syntax):
Code: Select all
convert \
\( \( 01.png -resize x498 \) \( 02.png \) +append \) \
\( \( 03.png -resize x497 \) \( 04.png -resize x497 \) +append \) \
-append \
result.png