Page 1 of 1

Particular generation time of imagemagick and Fred script

Posted: 2009-06-05T14:00:40-07:00
by badabou
Hello,

I have a problem with a script by Fred :
http://www.fmwconcepts.com/imagemagick/3Dbox/index.php

On the site of lunapic, the generation time of 3d animated cube is less than 2 seconds while on my server (Bi Dual Xeon 8x2Ghz) time is greater than 60 seconds :

http://www.lunapic.com/editor/?action=cubeanim

How to explain such a difference ?

Thank you and sorry for my English.

Re: Particular generation time of imagemagick and Fred script

Posted: 2009-06-05T14:21:47-07:00
by fmw42
badabou wrote:Hello,

I have a problem with a script by Fred :
http://www.fmwconcepts.com/imagemagick/3Dbox/index.php

On the site of lunapic, the generation time of 3d animated cube is less than 2 seconds while on my server (Bi Dual Xeon 8x2Ghz) time is greater than 60 seconds :

http://www.lunapic.com/editor/?action=cubeanim

How to explain such a difference ?

Thank you and sorry for my English.
It is not an ImageMagick problem, but one of using a script in place of a single true compiled function.

My 3dbox script has to do a lot of unix calculations to set up and rotate vertices, compute surfaces and test the surfaces for back facing and front facing. These take a lot of time as they are not part of the IM function -distort perspective and so are not compiled. Then -distort perspective has to be called multiple times, once for each face and the faces composited together. It is not a nice and neat compiled function, but a script that mixes unix calculations with a few IM functions. If you then animate it, the time inefficiencies get multiplied N time to slow it even further. Plus all the frames have to be duplicated as they are written to a gif animation. My script was not necessarily written with efficiency in mind, but could probably be tuned up to be more efficient. However, it will never achieve the same efficiency as a single true compiled function.

Lunapic probably has this all compiled into a single neat function and likely does it all in memory with no temporaries files written to disk.

Re: Particular generation time of imagemagick and Fred script

Posted: 2009-06-06T00:05:22-07:00
by anthony
You may also like to look at 3D Boxes, Affine Layering which shows how it can be done. Of course you still need calculations for the coodinates desired.

There is also an example of using Shears to generate a 3d Cube, that was developed and first exampled by Wolfgang Hugemann. It is shown again as part of his Windows Batch Scripting contribution to IM. Note however that this is even hard to do for any angle as its mathematics is not as precise.

Re: Particular generation time of imagemagick and Fred script

Posted: 2009-06-15T00:51:41-07:00
by badabou
Thank you very much for your responses.
I now understand how to optimize the scripts Fred.
Thank you very much for your script Fred and thank you designers imagemagick.