Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Custom text on gif

$
0
0
I have a list of individual images (26 in total - one image per alphabet word) and I would like to create an animated .gif depending on what the user types in an input, this gif should display the images one by one until the word is completed.

Example:
The user types: "Hello"
So I need my gif to have the following frames:
Frame 1: H
Frame 2: He
Frame 3: Hel
Frame 4: Hell
Frame 5: Hello

I use this code https://magick.codeplex.com/wikipage?title=Combining%20images&referringTitle=Documentation to create my animated gif but it overlays all the images and create the gif instead creating a single line adding the letters one by one.

Following my code
 using (MagickImageCollection collection = new MagickImageCollection())
            {
                var wordCounter = 0;
                foreach (var word in Message)
                {
                    if (File.Exists(OutputPath + string.Format("Words/{0}.png", word)))
                    {
                        collection.Add(string.Format("~/Words/{0}.png", word));
                        collection[wordCounter].AnimationDelay = 100;
                        collection[wordCounter].AnimationIterations = 1;
                    }                    
                    wordCounter++;
                }

                // Optionally reduce colors
                QuantizeSettings settings = new QuantizeSettings();
                settings.Colors = 256;
                
                collection.Quantize(settings);

                
                // Save gif                
                collection.Write(string.Format("{0}Words/{1}.gif", OutputPath, Message.ToLower()));
            }
Thanks

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>