Graphics - Generate GIF from bitmap files

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Media.Imaging;

class Program
{
    static BitmapSource BitmapSourceFromFile(string path)
    {
        var sr = File.OpenRead(path);
        var img = new BitmapImage();
        img.BeginInit();
        img.StreamSource = sr;
        img.EndInit();
        return img;
    }

    static void CreateGif(IEnumerable<string> images, string gifName)
    {
        using (var sw = new FileStream(gifName, FileMode.Create)) {
            var enc = new GifBitmapEncoder();
            foreach (var file in images) {
                var img = BitmapFrame.Create(BitmapSourceFromFile(file));
                enc.Frames.Add(img);
            }
            enc.Save(sw);
        }
    }

    static int Main(string[] args)
    {
        if (args.Length < 2) {
            Console.WriteLine("Usage: giffer InputDirectory OutputGifFileName");
            return -1;
        }

        var dir = args[0];
        var gif = args[1];
        if (!Directory.Exists(dir)) {
            Console.WriteLine("Error: input directory does not exist.");
            return -1;
        }

        var files = Directory.EnumerateFiles(dir, "*.bmp").OrderBy(x => x).ToArray();
        CreateGif(files, gif);
        return 0;
    }
}