🚨 rethumb will shutdown on September 4th, 2021 🚨 (Twitter)

<< More Tutorials

How to convert an image to JPG, GIF, PNG, TIF or WebP in C# using rethumb?

To convert an image to JPG, GIF, PNG, TIF or WebP in C# use the following code:

using System.IO;
using System;
using System.Net;

class CsRethumbExample
    static void Main()
        // First apply a square operation, then convert to PNG format.

        string paramOperation1 = "square";
        int paramValue1 = 100;

        string paramOperation2 = "format";
        string paramValue2 = "png"; // Other formats available: jpg, gif, tiff and webp.

        string imageURL = "http://images.rethumb.com/image_coimbra_600x300.jpg";
        string imageFilename = "resized-image.jpg";

        using (WebClient client = new WebClient())
            client.DownloadFile(string.Format("http://api.rethumb.com/v1/{0}/{1}/{2}/{3}/{4}", paramOperation1, paramValue1, paramOperation2, paramValue2, imageURL), imageFilename);

Start using this example now

Use the following commands to get started:

$ git clone https://github.com/rethumb/rethumb-csharp-examples.git
$ cd rethumb-csharp-examples
$ ... Use your IDE of choice to handle the file "format.cs"

More examples using C#