Page 1 of 1
composite help, need help with performance and shortening
Posted: 2008-11-02T04:38:31-07:00
by gotskill10
IM Version: 6.3.5
I have a relatively simple application of ImageMagick. I'm using it to take one image, and tile it on a large canvas while mirroring the image on the edges.
The entire time, Im only working with one image, but Im loading it into memory each time and calling functions that have already been called.
Can anyone help me take this down from 18 seconds in execution time? I've looked through the documentation and haven't been able to find anything.
convert -size 4320x4320 xc:white \
\( ./assets/bg.jpg -flop -geometry 3888x3888-3672+216 \) -composite \
\( ./assets/bg.jpg -flop -geometry 3888x3888+4104+216 \) -composite \
\( ./assets/bg.jpg -flip -geometry 3888x3888+216-3672 \) -composite \
\( ./assets/bg.jpg -flip -geometry 3888x3888+216+4104 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888-3672-3672 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888+4104-3672 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888-3672+4104 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888+4104+4104 \) -composite \
./assets/bg.jpg -geometry 3888x3888+216+216 -composite \
./assets/tiled_bg.jpg
What could this simplify to?
Re: composite help, need help with performance and shortening
Posted: 2008-11-02T05:00:58-07:00
by Bonzo
Does this have any effect ?
Code: Select all
convert -size 4320x4320 xc:white ./assets/bg.jpg -write mpr:image +delete \
\( mpr:image -flop -geometry 3888x3888-3672+216 \) -composite \
\( mpr:image -flop -geometry 3888x3888+4104+216 \) -composite \
\( mpr:image -flip -geometry 3888x3888+216-3672 \) -composite \
\( mpr:image -flip -geometry 3888x3888+216+4104 \) -composite \
\( mpr:image -flip -flop -geometry 3888x3888-3672-3672 \) -composite \
\( mpr:image -flip -flop -geometry 3888x3888+4104-3672 \) -composite \
\( mpr:image -flip -flop -geometry 3888x3888-3672+4104 \) -composite \
\( mpr:image -flip -flop -geometry 3888x3888+4104+4104 \) -composite \
mpr:image -geometry 3888x3888+216+216 -composite \
./assets/tiled_bg.jpg
I have not tested it; if it does not work try changing the first line:
Code: Select all
convert ./assets/bg.jpg -write mpr:image +delete -size 4320x4320 xc:white \
Re: composite help, need help with performance and shortening
Posted: 2008-11-02T08:34:39-07:00
by el_supremo
I've modified Bonzo's idea to use more temporary images so that fewer flips and flops are done which should save some time.
I haven't tested it but it should work.
Code: Select all
convert -size 4320x4320 xc:white \
\( ./assets/bg.jpg -write mpr:image -flop -write mpr:flop -geometry 3888x3888-3672+216 \) -composite \
\( mpr:flop -geometry 3888x3888+4104+216 \) -composite \
\( mpr:image -flip -write mpr:flip -geometry 3888x3888+216-3672 \) -composite \
\( mpr:flip -geometry 3888x3888+216+4104 \) -composite \
\( mpr:flip -flop -write mpr:flipflop -geometry 3888x3888-3672-3672 \) -composite \
\( mpr:flipflop -geometry 3888x3888+4104-3672 \) -composite \
\( mpr:flipflop -geometry 3888x3888-3672+4104 \) -composite \
\( mpr:flipflop -geometry 3888x3888+4104+4104 \) -composite \
mpr:image -geometry 3888x3888+216+216 -composite \
./assets/tiled_bg.jpg
Pete
Re: composite help, need help with performance and shortening
Posted: 2008-11-02T17:17:15-07:00
by anthony
As you are wanting a 'mirror tile' effect there is a vert tricky method that should be very fast...
Im have somethng calls 'virtual pixels' which define what pixel should be returned when you 'lookup' an image but MISS the actual image.
http://www.imagemagick.org/Usage/misc/#virtual
The new 'distort' function can 'lookup' an image and its surrounding virtual pixel 'space' without actually distorting the image (no-op).
http://www.imagemagick.org/Usage/distor ... rt_options
Also it has a special option that lets you create a larger 'view' of the distorting 'space' using a 'viewport' setting
http://www.imagemagick.org/Usage/distor ... t_viewport
so given your image, lets mirror tile it into a large area!
Code: Select all
convert ./assets/bg.jpg -set viewport 4320x4320+0+0 \
-virtual-pixel Mirror -distort SRT 0 +repage tiled_bg.jpg
Now is't that a lot better than all those flips and flops!!!!!
Of course you can distort the images too.. See Affine Tiling
http://www.imagemagick.org/Usage/distorts/#affine_tile
As a bonus this can work for multiple images simultaneously.
A feature that was put to good use to so a simple tile of an animations, specifically glitter tiles...
http://www.imagemagick.org/Usage/anim_m ... tter_tiles
Re: composite help, need help with performance and shortening
Posted: 2008-11-02T17:22:48-07:00
by fmw42
gotskill10 wrote:IM Version: 6.3.5
I have a relatively simple application of ImageMagick. I'm using it to take one image, and tile it on a large canvas while mirroring the image on the edges.
The entire time, Im only working with one image, but Im loading it into memory each time and calling functions that have already been called.
Can anyone help me take this down from 18 seconds in execution time? I've looked through the documentation and haven't been able to find anything.
convert -size 4320x4320 xc:white \
\( ./assets/bg.jpg -flop -geometry 3888x3888-3672+216 \) -composite \
\( ./assets/bg.jpg -flop -geometry 3888x3888+4104+216 \) -composite \
\( ./assets/bg.jpg -flip -geometry 3888x3888+216-3672 \) -composite \
\( ./assets/bg.jpg -flip -geometry 3888x3888+216+4104 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888-3672-3672 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888+4104-3672 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888-3672+4104 \) -composite \
\( ./assets/bg.jpg -flip -flop -geometry 3888x3888+4104+4104 \) -composite \
./assets/bg.jpg -geometry 3888x3888+216+216 -composite \
./assets/tiled_bg.jpg
What could this simplify to?
I don't know if this is exactly what you are trying to do as you have not provided an input and output image, but you may want to look at my tidbits on unfolding and mirror tiling at:
http://www.fmwconcepts.com/imagemagick/ ... php#unfold
http://www.fmwconcepts.com/imagemagick/ ... php#mirror
(credit to Anthony for most of these methods)
Re: composite help, need help with performance and shortening
Posted: 2008-11-03T15:40:34-07:00
by gotskill10
I was able to complete my task with this:
http://www.fmwconcepts.com/imagemagick/ ... php#unfold
Its taking me 13 seconds instead of 18. Thanks for all your help guys.