How to change the DPI of a photo using C# in .NET Framework

Adjusting photo DPI/PPI can be an important task for a photo app, design website, or any other application that needs to interact with a printer or other media output device. Manually adjusting DPI is not difficult with the help of existing photo applications, but becomes significantly more tedious when the solution needs to be automated or when working in bulk. Let’s look at how to apply a Cloudmersive API to solve this problem in two easy steps.

  1. Run the following command in your Package Manager console to install the API.
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 1.3.4

2. Call ConvertImageImageSetDPI and provide your desired DPI:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;
namespace Example
public class ConvertImageImageSetDPIExample
public void main()
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");
var apiInstance = new ConvertImageApi();
var dpi = 56; // int? | New DPI in pixels-per-inch, for example 300 DPI or 600 DPI
var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.
// Change image DPI
byte[] result = apiInstance.ConvertImageImageSetDPI(dpi, inputFile);
catch (Exception e)
Debug.Print("Exception when calling ConvertImageApi.ConvertImageImageSetDPI: " + e.Message );

And that’s all there is to it!

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store