3 Comments
  • Posted in:
  • C#

As you can read in the blogpost about access jpg’s through ftp with asp.net. I have explained there how I connected with FTP and retrieved images of the IP security camera. Now I have slightly modified the LINQ so that it downloads the latest 3 images and I would like to animate the transition between them. Now I know that I can use some fancy jQuery for image transitions, but I would like to merge the three images in a Gif.

Here is how I have accomplished it with Asp.Net C# [more]

I have searched the web for a decent and free Gif library and found this post on CodeProject from 2005!  (Epic!)

http://www.codeproject.com/KB/GDI-plus/NGif.aspx

So I have downloaded the sources and had to compile the DLL myself. Don’t worry. I will upload the compiled version so that it saves you some time. Please note that my Visual Studio 2010 converted the sources from 2005 to .Net 4. So that might be a problem.

Here is my snippet for taking 3 images of the FTP source and adding them as frames to the gif.

var fis = fc.ListDirectoryDetail(dirLast.FullName + "/").GetFiles("jpg").AsEnumerable().Reverse().Take(3);

string gifName = Server.MapPath("~/tempwrite/" + foldername + ".gif");

AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start(gifName);
e.SetDelay(500);
e.SetRepeat(0); //-1:no repeat,0:always repeat 
int counter = 0;

foreach (FTPfileInfo fi in fis)
{
    fc.Download(fi.FullName, Server.MapPath("~/tempwrite/" + foldername + counter + ".jpg"), true);
    e.AddFrame(System.Drawing.Image.FromFile(Server.MapPath("~/tempwrite/" + foldername + counter + ".jpg")));
    counter++;
}
e.Finish();

Credits for NGif go to gOODiDEA.Net

happy coding!

Download DLL:

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn

Comments

Comment by DotNetKicks.com

Make an animated gif with Asp.Net C#

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Comment by DotNetShoutout

Make an animated gif with Asp.Net C#

Thank you for submitting this cool story - Trackback from DotNetShoutout

Comment by syngu.com

Pingback from syngu.com

Make an animated gif with Asp.Net C# | ASP.NET, .NET, C# and LINQ | Syngu