Page 1 of 1
How to speed up GIF creation.
Posted: 2019-07-25T16:29:21-07:00
by gfilkov
Dear,
I am using Magick.NET-Q16-AnyCPU.dll version 7.12.0.0 in web app hosted in IIS
The app generates GIF using provided background image superimposed with number of smaller images (assets).
Assets are being scaled, rotated and positioned over background.
Typical background: 340x520 jpg.
Typical asset: 250x250 png.
Approximate number of assets - 100
Approximate number of frames - 60-80
Generation of GIF takes up to 2 minutes on the Azure app service.
I need to cut that time down al least to 30 seconds.
Please advise.
Thank you
Re: How to speed up GIF creation.
Posted: 2019-07-25T16:35:58-07:00
by fmw42
GIFs take time to generate, since they have to be quantized to 256 colors or less. You might consider using one common color table for all frames.
Imagemagick's color quantization is slow but does a good job. You might be able to speed it up by using a different tree-depth. See
https://imagemagick.org/script/command- ... #treedepth
Re: How to speed up GIF creation.
Posted: 2019-07-25T17:17:31-07:00
by gfilkov
Thank you for the prompt reply.
Yes, I am applying Quantize():
web.config
<add key="QuantizeColors" value="256" />
ImageMagick.QuantizeSettings settings = new ImageMagick.QuantizeSettings();
settings.Colors = quantizeColors; // from config
image.Quantize(settings);
Question:
I am compiling each frame by composing each asset on the frame.
Initially the frame is the clone of bkg image.
Will it be faster if the frame is initially set to transparent (empty) rectangle, and at the end, when all assets are placed on the frame, i compose the background image placing transparent-background frame on top of the background image?
Re: How to speed up GIF creation.
Posted: 2019-07-25T17:56:17-07:00
by fmw42
Sorry, I cannot answer that. I do not use Magick.Net
Re: How to speed up GIF creation.
Posted: 2019-07-29T12:03:04-07:00
by gfilkov
Anybody around who knows Magick.NET ins and outs?
Re: How to speed up GIF creation.
Posted: 2019-07-29T12:17:12-07:00
by snibgo
gfilkov wrote:Will it be faster if the frame is initially set to transparent (empty) rectangle, and at the end, when all assets are placed on the frame, i compose the background image placing transparent-background frame on top of the background image?
Why would it be faster? Placing the assets on a background image needs the same processing as on a transparent image, and then you would need an extra operation to place the result on the background. But you can test it to find out.
If you use the same assets and background on every frame, I assume you are not re-reading them. And I assume you are doing no other superfluous work.
EDIT to add: And I suppose you don't need floating-point, so have built IM without HDRI. Perhaps Q8 is sufficient.
Re: How to speed up GIF creation.
Posted: 2019-07-29T13:15:41-07:00
by gfilkov
> Perhaps Q8 is sufficient
This is important, thank you!
I am still using Magick.NET-Q16-AnyCPU.dll, by inertia.
I have started with that lib, then had to cut down the size and color depth, trying to speed up my app, but did not change DLL.
I will change the lib and see how much it helped.
Thanks