A huge continued thanks to imgix for sponsoring this week's Bites! imgix is real-time image resizing as a service. They allows us to resize, crop, and process images on the fly, simply by changing their URLs. Let's take a look.
By now we've learned all about how imgix has client libraries for all sorts of languages and environments, and how we might not even need one depending on our use case. That's part of what makes imgix so awesome, we can play around with size, crops, effects, even draw text or watermarks on images just by changing some URL parameters. They use our existing image storage locations as a source (supports public web folders, S3 buckets, and Web Proxies). We can configure multiple image sources, set caching times, and set custom domains on their site. Best of all, response times for images average around 70ms!
imgix is packed with features, here's a fun one: If we had an app that served up album art, it'd be neat if we themed our UI to match the colors in each album cover. With imgix, this is super simple! We just request the image's palette:
GET /albums/the-process-of-belief.jpg?palette=json&colors=5
imgix will then return some JSON containing colors we can set on our UI elements:
{
"average_luminance": 0.294337,
"colors": [{ "blue": 0.027451, "green": 0.847059, "red": 1 },
{ "blue": 0.603922, "green": 0.792157, "red": 0.427451 }]
}
If we were building a website, we could even specify a CSS class name and request the palette as 100% valid CSS. Then we could just include it with a tag in our .
Another really powerful feature of imgix is their intelligent cropping tools. If our app allowed folks to upload avatar images for their profiles, we could easily automatically crop those images right around the users' faces with an imgix URL like this:
GET /jony.jpg?crop=faces&fit=facearea&h=50&w=50&facepad=1.5
With that simple URL, imgix will:
- Find the face(s)
- Add some padding
- Crop the image
Stop maintaining your frankenstein ImageMagick setup and let imgix handle it. It's free to get started. Use the link littlebitesofcocoa.com/imgix so they know you heard about them here.