Page 1 of 1

what's the best way to combine multiple pics into one big pics

Posted: 2019-05-23T16:21:58-07:00
by niyanwen
Hey, I need to generate one big by combine around 20 small pics
each small pics I have its location(offset x, y) and I have the big image size

what is the best command to do with it?
if I used in java, is there any example to take a look?

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-23T16:33:45-07:00
by fmw42
What you probably want is to flatten all the images onto the background. You can do that in one command line using -flatten. See https://imagemagick.org/Usage/layers/#flatten. Sorry, I do not know the Java ImageMagick API nor do I know of any Java examples. See https://github.com/techblue/jmagick or search on Google or StackOverflow.

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T11:41:43-07:00
by niyanwen
Hi,

I follow this command, but the issue I face is the background of image is white or something else, do you know how to setup background as transparent, and only keep the images I want to combine

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T11:46:53-07:00
by niyanwen
the command generated is : convert -size 1990x3535 xc:transparent -page +0+0 image1.png -page +497+0 image2.png -layers flatten image3.png

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T11:57:43-07:00
by snibgo
Insert "-background None" before "-layers flatten".

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T12:38:41-07:00
by niyanwen
works! thank you! do you know why I need to have this "xc:transparent" in the cmd, looks like without this, it won't work

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T12:40:55-07:00
by fmw42
It sets the limits/size of your output. You can remove it, but if your images are smaller, then you would get a smaller output. If your images are larger, then they will be clipped to those bounds.

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T12:45:20-07:00
by niyanwen
got it, thank you!

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T12:52:14-07:00
by fmw42
You could remove the xc:transparent and use -layers mosaic. It will expand the canvas to so that all your images show. See https://imagemagick.org/Usage/layers/#layers

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T19:14:02-07:00
by niyanwen
but my use case for now is I need to set a default image size for the whole image, so I need to keep xc:transparent right?

Re: what's the best way to combine multiple pics into one big pics

Posted: 2019-05-28T19:52:54-07:00
by fmw42
Yes, I believe that would be so, if you need a particular size. I was just trying to reply to your question and explain your options.