The provided code demonstrates a simple console application that performs an Image Resizer.

Step 1. Create a new C# console application project. In Visual Studio, you can follow these steps.

Use the below code in Program.cs and replace all to Resize the Image from the folder.

Image Resizer

using System;
using System.Drawing;
using System.IO;

namespace ImageResizeConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Path to the source folder
            string sourceFolderPath = @"D:\ConsoleApplication\inputDirectoryPath\";

            // Path to the destination folder
            string destinationFolderPath = @"D:\ConsoleApplication\outputDirectoryPath\";

            // Desired width and height for the resized image
            int targetWidth = 800;
            int targetHeight = 600;

            // Get all image files from the source folder
            string[] imageFiles = Directory.GetFiles(sourceFolderPath, "*.jpg");

            foreach (string imagePath in imageFiles)
            {
                // Load the source image
                Image sourceImage = Image.FromFile(imagePath);

                // Create a new bitmap with the desired size
                Bitmap resizedImage = new Bitmap(targetWidth, targetHeight);

                // Create a graphics object from the resized image
                using (Graphics graphics = Graphics.FromImage(resizedImage))
                {
                    // Set the interpolation mode to high quality
                    graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                    // Draw the source image onto the resized image with the desired size
                    graphics.DrawImage(sourceImage, 0, 0, targetWidth, targetHeight);
                }

                // Generate a unique filename for the resized image
                string resizedImagePath = Path.Combine(destinationFolderPath, GenerateUniqueFileName());

                // Save the resized image to the destination folder
                resizedImage.Save(resizedImagePath);

                // Cleanup
                sourceImage.Dispose();
                resizedImage.Dispose();

                Console.WriteLine($"Image resized and saved: {resizedImagePath}");
            }

            Console.WriteLine("All images resized and saved successfully.");
        }

        static string GenerateUniqueFileName()
        {
            // Generate a unique filename using a timestamp
            string timestamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            string extension = ".jpg"; // or use the extension of your source image
            return $"resized_{timestamp}{extension}";
        }
    }
}

To test the code, follow these steps,

Resize Image in C# Console Application

I hope this blog post has provided you with an understanding of the Console Application to Resize an Image from a specific folder and save into a specific folder.

Thank you for reading, and happy coding!".