Resize Images C#

Image resizing is a common operation in image processing, useful for web publishing, thumbnails, or reducing file sizes. In this article, you will learn to resize raster images like JPG or PNG, perform proportional resizing, and handle vector images such as SVGs with precision.

Why Resize Images in C#?

Resizing images programmatically lets you automate and scale image processing without manual steps. Key benefits include:

  • Optimizing image size to reduce loading times and bandwidth in web apps.
  • Ensuring consistent display across platforms and screen sizes.
  • Generating previews and thumbnails dynamically.
  • Automating adjustments in workflows such as document generation, archiving, or publishing.

Resize Images - C# API Installation

Install the latest stable version of Conholdate.Total for .NET with this NuGet command:

PM> NuGet\Install-Package Conholdate.Total

Resize Images in C#

Start with basic resizing of raster images like JPGs using fixed dimensions:

  1. Load a JPG image from file with Image.Load().
  2. Call Resize() to set width and height to 300 px each.
  3. Save the resized image using image.Save().

The sample code below demonstrates image resizing in C#:

Resize Images Proportionally in C#

This section shows how to resize a PNG image while keeping its original aspect ratio.

  1. Load the PNG image with Image.Load().
  2. If the image is not cached, call CacheData() for better performance.
  3. Divide the current width and height by 2 to get new proportional dimensions.
  4. Use ResizeWidthProportionally() and ResizeHeightProportionally() to maintain the ratio.
  5. Save the resized image with image.Save().

The following snippet illustrates proportional resizing in C#:

Resize Vector Images in C#

This example explains how to resize a vector image (SVG) in C#:

  1. Load an SVG image using Image.Load().
  2. Multiply the current width and height by scaling factors (10 and 15).
  3. Call Resize() with the new dimensions.
  4. Save the result as PNG using image.Save() with PngOptions.
  5. Set SvgRasterizationOptions to ensure proper rendering of the vector.

The code sample below shows how to resize vector images in C#:

Free Evaluation License

You can evaluate these and many other API features by obtaining a free temporary license.

Summing Up

Image resizing is essential for applications that manage, display, or export visual content. With Conholdate.Total for .NET, resizing images in C# is efficient and developer‑friendly. It supports many formats and offers fine control over fixed dimensions, aspect‑ratio preservation, and vector conversion. If you have questions, feel free to contact us at the forum.

See Also