As much as I love building large, robust software systems and services, I often just want a quick script to solve a particular problem. In those instances I feel most comfortable dropping to the command line. With Algorithmia’s new CLI tool, I can quickly and easily access algorithms for a wide variety of tasks. With the entire Algorithmia marketplace readily available behind the command line interface, now it’s trivial to detect faces, make passport photos, encrypt messages, crawl a domain to build a site map, cheat at LetterPress or Sudoku, and much so more.
Recently I needed to convert a directory of images into thumbnails, with the goal of having each cropped to the same size without losing the focus on the face. While cropping a photo manually isn’t too bad if you just have to do it once, cropping a large set of photos by hand can be extremely time consuming and tedius. Lucikly, Algorithmia offers an algorithm to do just that: Smart Thumbnail.
The Algorithmia way
The Smart Thumbnail algorithm builds on the opencv-based Face Detection algorithm to detect faces and create thumbnails in one fell swoop. I started with this sample set of photos:
Combining the Smart Thumbnail algorithm with the Algorithmia CLI client, it’s simple to create a clean script for thumbnailing an entire directory:
for image in $@; do
echo "Processing $image"
algo run opencv/SmartThumbnail -D "$image" -o "$output_file"
This short and simple code makes it easy to batch process photos, and the results speak for themselves.
As you can see, each image is cropped to the same size, but no one is left with a half a head or their face cut in two. Instead of having to manually crop each photo so that the faces are preserved, I can just run all the photos through the Smart Thumbnail algorithm. Not only is it the intuitive output I was hoping for, but it was also a simple CLI experience with just one clean tool.
One tool, any algorithm
With the Algorithmia CLI I now have a powerful set of algorithms available to me for use across any project or platform. With access to any algorithm in the marketplace, I can now reach for one tool to perform a variety of tasks. Sign up, install the CLI, pick an algorithm, run it with a simple:
algo run <algorithm> -d '<data>'
algo run <algorithm> -D '<file>'
And enjoy your supercharged command line!
Let us @algorithmia know how you plan to use the Algorithmia CLI. Include #SuperchargedCLI and your Algorithmia username for 10,000 free credits.