Developer API’s for better and faster image compression

A website with a lot of photos takes a long time to load. A long loading time will shorten the time visitors stay on your website. Compressed images make your page speed way faster. Using a developer API is a quick solution to compress a lot of photos in no time. But what is an API and how can you compress images with it?

What is an API?

An API, also known as an Application Programming Interface, connects different devices and applications with each other. It’s a software intermediary that ensures that two applications can interact. You could say that one application (the messenger) makes a request to another application (a provider) and then feeds back the response.

You probably use an API more often than you think. Let’s say, you want to book a flight and you want to compare different airlines. In most cases, you will use a travel service website to do the comparison, instead of visiting each individual airline website. This travel service website interacts with multiple airline APIs to get the information you are asking for. After you type in your preferences, the travel agency website will request this information via the airlines’ APIs. After receiving the API call, the airline will respond back with the available options. Now the travel agency website will collect the information and present the different options available that meet your search criteria.

An API key

For some companies, it’s important to have insight into the API use of certain users. This is done with an API key that users need to implement in their website’s code. It’s an unique code that allows the API to identify the calling user or program. In the given example, there are probably many travel agencies using the Airline’s API. Each of these agencies has an API key that is required when making the API calls. This way the airline can know which agency has made a specific booking or even find out what kind of searches are done most often by a certain agency.

API for image optimization

For image optimization there are also APIs available that can simply connect an image compression service to your website. This connection makes compressing the pictures on your website possible. For example, you can have your images automatically compressed during upload. You can upload them to a service via the API. Once it is compressed, you then can use the API to retrieve the optimized image and replace the original image. For most image optimization services an API key is needed, so the provider can keep track of how many files you have compressed. 

Why compressing images with an API?

Instead of manually uploading all your images within an online compression tool, an API allows you to compress the files after uploading them on the website. The process is faster and saves you a lot of work. Besides, most companies offer extra features within the API service, for example resizing the photos. The list of features will be unique to each provider.

An API for image compression can be interesting for many types of users. When you have a lot of photos on your website or often upload new ones, an API can be extremely helpful. If you for example have a webshop with an always changing assortment, it would save a lot of time to optimize your images automatically via an API. Besides, you can enjoy the extra features it mostly offers. 

How to compress images with the Tinify Developer API?

To compress images with the Tinify Developer API, you first need an unique API key. You can receive an API key by registering with your name and email address on the website. After retrieving your key, you can immediately start reducing the file sizes of your images. You can upload any WebP, JPEG or PNG file to the API to compress it. Tinify’s developer API automatically detects the type of the image and optimizes the file. Compression starts as soon as you upload a file. You can follow your number of compressions at the Tinify dashboard or via an API call.

The Tinify API is available for Ruby, PHP, Node.js, Python, Java and .NET and HTTP requests. Besides, there are some third-party companies and enthusiastic developers who created helpful scripts that you can use. You can find the solutions here. In case you need support with any of these solutions please contact the add-on developer directly.

Additionally, if your website is built in WordPress then there is a plugin available to compress your photos. It’s easy to install and the plugin has different ways to compress existing images and newly uploaded images. If you like to know more about the WordPress Plugin, click here

Features Tinify API

Most APIs provide additional features within the service. Tinify API offers the neat feature of resizing your optimized images. You only have to upload the original once and then it can generate an optimized version in the requested image size. Resizing includes correct gamma scaling, bicubic transparency edge correction and natural image sharpening. In addition, you can also take advantage of smart cropping to create thumbnails with different aspect ratios. The API will resize your images and crop away the parts that are visually the least interesting.

On top of this feature, the Tinify compression engine is able to detect free-standing objects on plain backgrounds. When changing the aspect ratio, it will add background space or remove superfluous areas. This way the object in your image will remain free-standing and does not get cut-off at the edges when resizing. If you would like to know more about Tinify API and its features, please click here. 

Added background space by the Developer API (example)

In short…

In this blog we’ve discussed what an API is and why it can be helpful. An API is a great solution to integrate the image optimization process in your website. It can save you a lot of time. Next to image compression, Tinify’s developer API also offers other cool and helpful features. You will receive 500 free compressions each month and no payment details are needed for signup. For more details, check out the website