Pistitium.JpegFileSizer 1.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pistitium.JpegFileSizer --version 1.0.9
NuGet\Install-Package Pistitium.JpegFileSizer -Version 1.0.9
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pistitium.JpegFileSizer" Version="1.0.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pistitium.JpegFileSizer --version 1.0.9
#r "nuget: Pistitium.JpegFileSizer, 1.0.9"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Pistitium.JpegFileSizer as a Cake Addin
#addin nuget:?package=Pistitium.JpegFileSizer&version=1.0.9

// Install Pistitium.JpegFileSizer as a Cake Tool
#tool nuget:?package=Pistitium.JpegFileSizer&version=1.0.9

Pistitium.JpegFileSizer

Pistitium.JpegFileSizer provides a class to resize a JPEG image file to optimize size on disk while preserving image quality.

Installation

Install via Visual Studio Manage Nuget Packages... or download:

https://www.nuget.org/packages/Pistitium.JpegFileSizer

.NET CLI
> dotnet add package Pistitium.JpegFileSizer --version 1.0.X

Usage

using Pistitium.Framework.ImageAndGraphics;

namespace Pistitiumizer.Tester
{
    public class JpegFileSizerTester
    {
        // This event handler creates a thread that calls a 
        // Windows Forms control in a thread-safe way.
        private static void OnJpegFileResizerBroadcastStatus(string msg)
        {
            Console.WriteLine(msg);
        }

        // This event handler creates a thread that calls a 
        // Windows Forms control in a thread-safe way.
        private static void OnJpegFileResizerBroadcastResult(JpegFileResizer.ResultCode code)
        {
            Console.WriteLine(code.ToString());
        }

        public void Run()
        {
            Console.WriteLine("Inside JpegFileSizerTester.Run()");
            Console.WriteLine();

            string workingPath = "D:\\Pictures\\2018-04";
            bool createThumbnails = true;

            JpegFileResizer.BroadcastStatus += new JpegFileResizer.StatusNotification(OnJpegFileResizerBroadcastStatus);
            JpegFileResizer.BroadcastResult += new JpegFileResizer.ResultNotification(OnJpegFileResizerBroadcastResult);

            Console.WriteLine(string.Format("Resizing Files in Folder: {0}", workingPath));

            try
            {
                // output directory will be created as "Resized" under the working path
                JpegFileResizer.ResizeImages(workingPath, createThumbnails);
                
                // You can also specify the output path
                JpegFileResizer.ResizeImages(workingPath, outputPath, createThumbnails);
                
                // You can just create thumbnail images
                // output directory will be created as "Thumbnails" under the working path
                JpegFileResizer.CreateThumbnails(workingPath);
                // or
                JpegFileResizer.CreateThumbnails(workingPath, outputPath);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.10 88 4/18/2024
1.0.9 270 2/14/2023
1.0.8 268 1/18/2023
1.0.6 271 1/9/2023
1.0.5 313 1/3/2023
1.0.4 290 12/17/2022

Added:
public static void CreateThumbnails(string workingDirectory)
public static void CreateThumbnails(string workingDirectory, string outputDirectory)

Updated Readme file with sample code

See Readme file