API Reference

The Tinify API allows you to compress and optimize JPEG and PNG images. It is designed as a REST service. An official client library for Microsoft .NET is not yet available.

Basic C# with .NET example

Shown below is a basic example for compressing images with C# in Microsoft .NET.

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

class Program {
  static void Main() {
    string key = "<your api key>";
    string input = "large-input.png";
    string output = "tiny-output.png";

    string url = "https://api.tinify.com/shrink";

    WebClient client = new WebClient();
    string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes("api:" + key));
    client.Headers.Add(HttpRequestHeader.Authorization, "Basic " + auth);

    try {
      client.UploadData(url, File.ReadAllBytes(input));
      /* Compression was successful, retrieve output from Location header. */
      client.DownloadFile(client.ResponseHeaders["Location"], output);
    } catch (WebException) {
      /* Something went wrong! You can parse the JSON body for details. */
      Console.WriteLine("Compression failed.");

Need help? Got feedback?

We’re always here to help, so if you’re stuck just drop us a note on support@tinify.com. It’s also the perfect place to send us all your suggestions and feedback.

Try TinyPNG with a new browser

TinyPNG is created for modern browers with HTML5 & CSS3 support. We have not tried it out in other browsers. The site may work, or it may not. If you see this message you may want to try a different browser!