On-demand Image Resizing API
Hello guys. Today I’m going to share with you a very cool project I’m working on. Its main mission is to apply all Web Development Best Practices applied for images and combine them into one simple but powerful API.
First of all, if you have a website (or an app) with posts, news, galleries, or dealing with user-generated content, in general, it can be a huge waste of time if all you want to do is to focus on your business.
Usually, you have to create a new machine and optimize this web service to handle huge payloads, optimize its storage to fast access, increase timeouts to be able to fetch all the information, handle security, conversion, compression, and then you have to code a routine to generate thumbnails and resize your images in all kind of different formats you need (or may need) to be able to beautifully display those images on your app or website. After doing all that, you still need to sign up for a CDN so you can put your assets closer to your end-users to reduce latency and download speed.
It should be the dream, right? but we have to be honest… not all of us have the time, resources, and patience to go this further and do it all over again for each product or client you have.
First of all, to be able to keep up you need to go to the ImageBoss website and set up your account: https://imageboss.me/. (~30secs)
After login in, on your dashboard, you will be able to see this screen:
All you need to do is to add all the sources/hosts that identify your traffic. (You can add as many sites as you want).
In this example I will use this image:
Imagine that you want to generate a custom version of that image to be able to show it on a mobile device with 745×200.
In that case, I will use an ImageBoss operation called “cover” with all the default settings. You can read further by following this link:
Basically, all you need to do is add a prefix to the original URL:
And the final URL should be:
Notice that ImageBoss has Smart Cropping by default.
Use cover when you want an image with an exact width and height. By default, we’ll run our Smart Cropping algorithm to identify the main subject of the image, so in case we need to remove part of the image to deliver on the requested size, we will always try our best to keep the most important element in the frame.
In addition to all that it auto-rotates my image if necessary and it also converts my image to have progressive scans (progressive JPEG). Now my image is auto rotated, compressed, cached, progressive scans, and globally available to all my users.
I guess that our boring days generating thumbnails manually for every single project is over, right?
Let me know what you guys think!