Exemple #1
0
        public void ProcessFolder(string sourcePath, string destinationPath, int imageSize)
        {
            ImageResizer imageResizer   = new ImageResizer();
            string       fileTypeFilter = Properties.Settings.Default.FileTypeFilter;
            var          listOfFiles    = Directory.GetFiles(sourcePath, fileTypeFilter);

            foreach (var file in listOfFiles)
            {
                string fileName = destinationPath + @"\" + Path.GetFileName(file);
                imageResizer.ImageResizeAndSave(file, destinationPath, imageSize);
            }
        }
Exemple #2
0
        async static Task Main(string[] args)
        {
            var resizer = new ImageResizer(1500, 100L);

            var allFiles = System.IO.Directory.GetFiles(@"C:\original_images\amandeep\");

            foreach (var file in allFiles)
            {
                var outputStream = resizer.Resize(file, ImageFormat.Tiff);
                using (outputStream)
                    using (var fileStream = File.Create($@"C:\imageresize\{Path.GetFileName(file)}"))
                    {
                        outputStream.Seek(0, SeekOrigin.Begin);
                        await outputStream.CopyToAsync(fileStream);
                    }
            }

            allFiles.ToList().ForEach(file => File.Delete(file));
        }