Recognizing Objects in House Interior and Recommending Products with Image Recognition

There is a saying that If you want to become an expert of a field, you have to be a master of classification. Photographers can tell if their latest picture was beautiful or not. Musicians can classify what sounds great. Good developers can smell a good code snippet and a bad one.

Categorizations can take many hours of training for humans. Luckily, in the age of machine learning, the machines can help and save a ton of labor time for us. Today, we are going to got our feet wet by creating a photo categorizer app from scratch.

The mobile app we’re building is a demo. You can use it as a foundation for more complex photo organization application or as functionality within another specific application. It will take one image selected by the user, upload to Imagga APIs and categorize it. This is the final result:



Source Code

If you are looking into the code directly, feel free to skip reading and download from the side bar on right side. To get the code running, you will need to sign up with an Imagga Hacker Plan (free), get the authorization header and replace ‘YOUR_AUTHORIZATION_HEADER’ in the code. In ViewController.swift, change ‘authorizationHeader’ constant to the value of your own key. The key looks like: “Basic xxxx” as in the red square below:

The Imagga API

To start, let’s test our Imagga account by using this curl request from command line. This way, we can make sure that our setup is ready for the app. Here is the test image.

'curl --request GET \
--url '' \
--header 'accept: application/json' \
--header 'authorization:YOUR_AUTHORIZATION_HEADER''

After running the code above, we should got the result like this:

{"result":{"categories":[{"confidence":99.9999542236328,"name":{"en":"interior objects"}}]},"status":{"text":"","type":"success"}}

Now, we confirmed that the API key works for us. Notice in the above example, we used an URL of the image file. However, the app we are going to build will use an Image file instead of an image URL. So let’s see what the API doc has to say about that.

Navigate to the developer’s page, API Endpoints section and categories subsection: Imagga REST API Documentation. We can see it asks us to send a post request to this end point, and the parameter is “image” and with image file content. Be sure to keep this in mind because we gonna use it later. It’s time to code!

iOS Project Setup

Create a Xcode project, give it a name ‘Imagga’, select ‘Single View App’ and choose Swift as the language. In order to make the process faster, we are going to use two libraries: ‘Alamofire’ and ‘SwiftyJSON’. Make sure you have a podfile, set the platform to iOS12 and have the pods like this:

# Pods for Imagga
pod 'Alamofire', '~> 4.8'
pod 'SwiftyJSON', '~> 4.0'

We are going to use ‘Alamofire’ for uploading and ’SwiftyJSON’ for parsing the json responses. To manage the libraries, we use cocoapods. Make sure you have installed both pods before moving to the next section.

A Simple Upload in Swift

First thing first: Upload image to our API. Open ‘ViewController.swift’ and add the following below

import SwiftyJSON
import Alamofire

This will let you use the Alamofire module in your code. Next, create a function ‘sendImageToServer(image: UIImage)’ and add the following to it:

func sendImageToServer(image: UIImage) {
    guard let imageData = image.jpegData(compressionQuality: 0.5) else {
        print("no image data find")
    upload(multipartFormData: { (multipartFormData) in
                                 withName: "image",
                                 fileName: "image.jpg",
                                 mimeType: "image/jpeg")
           to: "",
           headers: ["Authorization": authorizationHeader,
                     "accept": "application/json"],
           encodingCompletion: {encodingResult in
            switch encodingResult {
            case .success(let upload, _, _):
                upload.responseJSON { response in
            case .failure(let encodingError):
  1. First, reduced the compress quality of the image to 0.5, so the file size will be smaller when we upload it to server.
  2. Upload an image named “image.jpg” and with a parameter name ‘image’ —— this is very import. If you recall from the Imagga API section, in order to upload a file, the parameter name we have to use is “image”.
  3. Send the file to end point:, make sure the authorizationHeader is setup correctly in the headers.
  4. Print the responses.

In order to test this upload function, let’s grab an image file from the project. You can download it here and add it to your Xcode project. After it’s added, let’s do a test to make sure our upload function works. Add the following into ‘viewDidLoad()’:

override func viewDidLoad() {
    // Do any additional setup after loading the view, typically from a nib.
    guard let image = UIImage(named: "entrywayheroscaled.jpg") else {
        print("no image found")
    sendImageToServer(image: image)

and we should see this response from the server

[Result]: SUCCESS: {
    result =     {
        categories =         (
                confidence = "99.9999542236328";
                name =                 {
                    en = "interior objects";
    status =     {
        text = "";
        type = success;

In, there’s a more detailed tutorial of how to use Alamofire, SwiftyJSON with Imagga API here: Since we’re more focused on using the API, I’ll leave the Swift side—digging to you:)

Handle Return Value

The next step after we have printed the response is to handle it and save it to our data module. Add the following function to ViewController.swift

func handleResponse(response: DataResponse<Any>) {
    guard response.result.isSuccess,
        let value = response.result.value else {
            print("Error while uploading file: \(String(describing: response.result.error))")
    self.personalPhotos = (JSON(value)["result"]["categories"].array?.map { json in
        PersonalPhoto(name: json["name"]["en"].stringValue,
                      confidence: json["confidence"].doubleValue)

and in ‘sendImageToServer(image: UIImage)’ function, add

self.handleResponse(response: response)

after ‘debugPrint(response)’.

Inside the ViewController class, add

var personalPhotos: [PersonalPhoto] = []

before ‘viewDidLoad()’ function.

Here’s a step-by-step explanation of the code above:

  1. Check that the response was successful. If not, print the error.
  2. Use ‘SwiftyJSON’ to retrieve the ‘categories’ array from the response. It iterates through each of the categories and transforms it to a PersonalPhoto struct.
  3. Save the array into ‘self.personalPhotos’.
  4. Put it inside a call back block after sending the image.
  5. Add a variable in ViewController to save the categories.

We don’t have a PersonalPhoto struct yet, so let’s create one. Create a new file named: PersonalPhoto.swift. Add the following to it:

struct PersonalPhoto {
    var name: String
    var confidence: Double

Run the project, and set a breakpoint right after we assigned value to self.personalPhotos. We should see one PersonalPhoto object in the array.

That means we are good for upload image and parse the responses. Now it is time to show the results in UI.

Connect UI in Xcode

Let’s see our app UI in the Main.storyboard file.

There are three main items: 1. Image view, 2 Table view 3. Select button.

Here are my constrains:

  • Image view: Height 200, leading & trailing space 10, top space 20, horizontal center. Default image: ‘entrywayheroscaled.jpg’, set contentMode to ‘Aspect Fit’
  • Select button: Height 50, Width 100, horizontal center, top to Image View 20
  • Table view: Height 200, leading & trailing space 10, top to Select button 20

Drag a prototype UITableViewCell into the tableview, and give it a container view, a confidence label on the left and a name label on the right. Tweak the label size, color and position as you would like. Make sure you connect the IBOutlets into ViewController.

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var tableView: UITableView!

Now our UI is good to go.

Select Photo from User Library

Since we are going to select the photo from user’s photo library, we connect ‘Select Button’ IBAction event into a buttonPressed function:

@IBAction func buttonPressed(_ sender: Any) {

and call ‘openPhotoLibraray()’ function inside it.

In order to open the system photo library, add ‘UIImagePickerControllerDelegate’ and ‘UINavigationControllerDelegate’ to the ViewController class.

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDataSource {

The calling system photo library part is straight forward:

func openPhotoLibraray() {
    if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
        let picker = UIImagePickerController()
        picker.delegate = self as UIImagePickerControllerDelegate & UINavigationControllerDelegate
        picker.sourceType = .photoLibrary
        self.present(picker, animated: true) {

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    picker.dismiss(animated: true)
    guard let image = info[.originalImage] as? UIImage else {
        print("No image found")
    imageView.image = image

Now if you build and run the project, “Select Photo” button will give you the build-in photo library and you can choose a photo. The Image View will display the photo you selected.

Connect Two Parts Together

We now have two parts:

  1. Upload an image to server and handle the responses.
  2. Select an image from the user photos library.

Let’s remove all the testing code inside ‘viewDidLoad()’, and in the last line of

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any])

add ‘sendImageToServer(image: image)’ right after ‘imageView.image = image’. Build and run the project, select a photo from your library, and you should see the responses in the logs.

UI Tweaks

It is time to display the responses in UI. We are going to show the result like below:

It is a tableview with multiple cells. In each cell, we display the categorizer’s name, confidence and the color indicator in the background.

To get the tableViewCell to work, create a subclass of UITableViewCell and name it ‘PersonalPhotoCell’ and connect all three IBOutlets

class PersonalPhotoCell: UITableViewCell {
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var confidenceLabel: UILabel!
    @IBOutlet weak var containerView: ConfidenceView!

and ConfidenceView.swift as follow:

import UIKit
class ConfidenceView: UIView {
    @IBInspectable var confidence: Double = 0 {
        didSet {
    override func draw(_ rect: CGRect) {
        // Drawing code
        let color = UIColor.init(red: 123.0/255.0, green: 184.0/255.0, blue: 183.0/255.0, alpha: 1.0)
        let rectToDraw = CGRect(x: 0, y: 0, width: CGFloat(rect.size.width) * CGFloat(confidence), height: rect.size.height)
        let path : UIBezierPath = UIBezierPath(rect: rectToDraw)

The ConfidenceView.swift is a subclass of UIView, and we use it as a container. The view only draw the percentage of confidence with color. This way it gives a good visual impression of the confidence level. In the tableView delegate:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return personalPhotos.count

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! PersonalPhotoCell
    let personalPhoto = personalPhotos[indexPath.row] as PersonalPhoto
    cell.nameLabel.text =
    cell.confidenceLabel.text = String(format: "%.2f%%", personalPhoto.confidence)
    cell.containerView.confidence = personalPhoto.confidence / 100.0
    return cell

We use our variable personalPhotos as the data source and set it accordingly to display in the cell. Notice those two lines:

cell.confidenceLabel.text = String(format: "%.2f%%", personalPhoto.confidence)
cell.containerView.confidence = personalPhoto.confidence / 100.0

We want to format it with two decimal points and also control the confidence value between 0 ~ 1 for the confidenceView.

Now if you run the project and select a photo, nothing is going to happen. But why?

This is because we haven’t updated our tableview after receiving the responses, so let’s do that now. In the upload image function, add


right after ‘self.handleResponse(response: response)’, this way we’re going to have an updated tableview once handled all the responses.

Run the project, select a photo you like and the server gonna return a categorizer it fits. And now, we’re good!

Best API Practice

Before we wrap up our tutorial, I want to emphasize on the best practices of the API: Imagga REST API DocumentationFor the image size:

The API doesn't need more that 300px on the shortest side to provide you with the same great results

And for a good confidence level:

Our suggestion is setting the confidence threshold at 15-20%.

So with those two points in mind, if you want to make the upload faster while keep the same quality, crop the image’s shortest side to 300px. Also, by filtering out all the categories with a confidence less than 80%, you will get a more accurate result.


Today we’ve gone through how to use the categorization API and create the iOS app from scratch by using Swift. Hope you enjoy the reading and had fun . Feel free to leave any questions and keep me updated on what you going to build next. Cheers!


Imagga REST API Documentation

Categorization API for Image Classification | Imagga Solutions

Alamofire Tutorial: Getting Started |

Create Autotagging Uploads with NodeJS using Image Recognition API – Imagga Blog

How to Make an Image Classifier – Intro to Deep Learning #6 – YouTube

Free iOS App with Image Recognition

Marketing Permissions For Imagga

We are always concious about sending a lot of emails, so our commitment is that we will send only when there is something interesting or free knowledge that we would like to share with you. If you feel like we are not living up to that expectation you can unsubscribe at any time by clicking the link in the footer of our emails.

Why Using Image Recognition Software Can Save Your Cloud Platform a Ton of Resources

In recent years, we have seen significant growth in artificial intelligence technology and its use in different industries such as automotive, healthcare, e-commerce, gaming, e.t.c. Image recognition, one of the flagship applications of AI, has had wide adoption across industries. It is estimated that the worldwide market for image recognition will grow to $29.98 billion by 2020.

A major factor in the growing demand for image recognition technology has been the increased use of the internet and the move of small and medium enterprises (SMEs) to the cloud. With this move, the businesses have benefited from some of the advantages a cloud platform offers such as widespread reach, scalability, flexible billing options, rapid deployment and constant availability. With the move to the cloud, businesses have found it necessary to adopt technology that helps them better navigate the smarter and more connected platform; and image recognition is one of those technologies.

Image recognition (sometimes called computer vision) is the ability of software to analyze an image or video, identifying its content e.g. people, objects, places and text. It is widely used in different industries e.g. in self-driving cars, facial and optical character recognition software, disease diagnosis, e.t.c. For businesses that operate in the cloud, image recognition can offer numerous benefits as outlined below.

Automating Tasks with Image Recognition Software Saves Time

Unlike other resources that you can create or acquire more of, time is a finite resource that most likely, to stay competitive, you can't afford to waste.

Without a doubt, computers are faster than humans at some particular tasks, and so for those tasks, it makes sense to automate the job using software, leaving your employees free to work on other urgent tasks. Image recognition software can be used to automate such tasks as categorizing and tagging media content, content moderation and editing images (e.g. cropping or background removal).

Use of Image Recognition Software can Help Keep your Team Lean and Thus Save Costs

Use of image recognition software can reduce or eliminate required labour. Without image recognition, you would have to put people on the job to do such tasks as tagging and categorizing your digital assets, moderating user-generated content, individually editing images, e.t.c. In some cases, such a feat might be annoying and frustrating at best, but in other cases, it might be outright impossible to do. Take, for instance, a firm that might be offering Digital Asset Management services. The firm might have several clients, each having millions of digital content that needs to be processed. It would be very difficult, if not impossible to run such a service on manual labour alone. To keep its client's happy, the business will have to keep its asset processing time to a minimal, which means it would have to keep a lot of people on board to do the work. With time, as its client list increases or as the content each client maintains increases, the business's labour costs will also be skyrocketing. Running such a business on manual labour alone isn't sustainable. By automating some tasks with image recognition software, you can maintain a lean and cost-effective team.

Image Recognition can Reduce Human Error

To err is human, to forgive divine so the saying goes; but when you are running a business that depends on the accuracy of its operations, you might not be so lax about errors that might occur.

Human labour is susceptible to making errors. When tasked with entering a large amount of data, it is probable that some data will be recorded incorrectly. Human labour is also prone to tiring. When one has to process thousands of images or videos, they might not be as keen on processing a few thousands. With exhaustion and waning focus, errors might creep in here and there.

For some use cases, image recognition has been shown to give better results than humans. In the medical field, for instance, there is a visual recognition software that has a higher success rate in diagnosing a particular type of cancer. In the still infant field of self-driving cars, it has been said that driverless cars are safer than human drivers.

Image recognition can help eliminate or at least reduce the inaccuracies of human intervention. This will, in turn, save the business resources that would have been lost due to the errors, whether in the form of revenue, labour or time.

Image Recognition can Help you Innovate According to Market Trends

One advantage of running an online business is that a lot of your customers are also online. In this connected ecosystem, it is easier to monitor the market by observing what people share online. By analyzing visual content that is shared online, you might be able to recognize a trend that you can piggyback on when it comes to product release. With image recognition, you can also gain some insights into your competitors by detecting their online visual presence. You can observe how the market engages with the competitor's visual content and determine if their reaction to it is positive or not. This can, in turn, inform your product design decisions.

Instead of using tedious questionnaires and discovery processes to find out what users want, you can use data to determine this. You can determine what users gravitate towards online by observing what they share and how they react to different content. An example of this in use is Netflix which uses data to determine what shows to create. This can save you the effort and cost of creating something that won't be profitable once it hits the market.

Image Recognition can Improve your Marketing Efforts

Other than using image recognition to predict products that will be popular amongst your target market, you can also use it to determine how best to market the products to consumers. Using image recognition, you can mine your target market's visual content and monitor market trends in real time. In this way, you can gain insights on how visual posts spread online, what type of visuals get the most attention, the type of people engaging most with your content, the individual influencers driving most of the traffic and the best platform to post your content on. This can, in turn, help you launch marketing campaigns that are most likely to succeed. Your marketers don't have to waste their budget guessing at what will work, they can use data to decide on the way forward.

How something is presented can have a huge impact on the level of engagement people will have with it. Netflix discovered from conducting consumer research, that the artwork on their website was not only the biggest influencer to a member's decision to watch content, but it also constituted over 82% of their focus while browsing. This is why they go through so much effort to determine the best artwork to display on their website, a feat that would be impossible without image recognition and machine learning. If you are running an online business, you should pay attention to how you present your product or service. In a world where consumers are spoilt for choice when searching for a product or service, you should ensure that your website communicates the value of what you are trying to sell in the best way possible.

Image Recognition can Help Online MarketPlaces Fight Counterfeit Goods

According to the Organization for Economic Co-operation and Development (OECD), counterfeit products may cost the global economy up to $250 billion a year. Businesses running online platforms that allow sellers to sell goods always run the risk of having some sellers selling counterfeit products. This can damage the marketplace's reputation when consumers get products that are subpar to their genuine counterparts.

To counter this, marketplace websites have started turning to image recognition technology to help identify legit and counterfeit products. Using software, the platforms put uploaded product images through some checks to ensure their authenticity.

In General, Image Recognition Makes for Better Apps

Overall, incorporating image recognition improves the user experience of cloud applications and makes their operation effective and efficient. Using better apps is good for any business's bottom line as they reduce the overall overhead costs.

In the presence of numerous competition, most companies compete primarily on the basis of customer experience. Poor user experience can lead to customer churn, and in an interconnected world, it is very easy for disgruntled customers to spread the word about the terrible service they had at your hands; so it is always in your best interest to employ any technology you can to produce the best possible product for your target market.

Do you use image recognition in your product? If yes, let us know how you use it and how it has improved your business. If you would like to find out more about the Imagga Image Recognition API, please contact us and we'll get back to you promptly.


Image Recognition Revolutionizes the Online Experience for the Visually Impaired

People take seeing and technology for granted. For a specific group of internet users, the online experience is not so straightforward. The visually impaired need special assistance to experience the digital world. There are a few diverse low-vision aids but generally, they can be divided into two categories: translating visual information into alternative sensory information (sound or touch) and adapting visual transformation to make it more visible. However, the bigger problem remains how to help people who are blind. The emerging technology for assistance in this category uses image processing techniques to optimize the visual experience. Today we will be looking at how image recognition is revolutionizing the online experience for the visually impaired.

Blind Users Interacting with Visual Content

Let’s stop for a second to consider the whole online experience for the visually impaired. What happens when a regular person sees a webpage? He scans it, clicks links or fills in page information. For the visually impaired, the experience is different. They use a screen reader: a software that interprets a photo or image on the screen and reads it to the user. However, to narrate each page element in a fixed order including skipping is not easy. Sometimes there is a vast difference between the visual page elements (buttons, banners, etc.) and the alt-text read by the screen reader. SNS pages (social networking service) with unstructured visual elements and an abundance of links, with horizontally and vertically organized content make listening to the screen reader more confusing.

Interacting with Social Visual Content

SNSs make it easy to communicate through various types of visual content. To fully engage with images, visually impaired people need to overcome accessibility challenges associated with the visual content through workarounds or with outside help.

Advancements in artificial intelligence are allowing blind people to identify and understand the visual content. Some of them include image recognition, tactile graphics, and crowd-powered systems.

Facebook has already algorithmically generated useful and accurate descriptions of photos on a larger scale without latency in the user experience. They provide visuals a description as image alt-text, an HTML attribute designed for content managers to provide the text alternative for images.

Web Accessibility  Today

We might think that web accessibility is a universal thing, but web designers do not always have the resources to devote to accessibility or do not see the value in making sites accessible. A 2-dimensional web page translated into a 1-dimensional speech stream is not easy to decipher. One of the most annoying things is that the majority of websites have insufficient text labeling of graphic content, concurrent events, dynamic elements, or infinitely scrolling pages (i.e. a stream of feeds). Thus, many websites continue to be inaccessible through screen readers. Even the ones that are intended for universal access: library websites, university websites, and SNSs.

The World Wide Web Consortium (W3C), an international community where Member organizations and the public work together to develop Web standards, created accessibility standards.  Led by Web inventor Tim Berners-Lee and CEO Jeffrey Jaffe, W3C's mission is to lead the Web to its full potential.

Solutions Helping Visually Impaired Users

There is a new iPhone app which uses machine learning to identify objects for visually impaired people without an Internet connection. The free image-recognition app is called Aipoly and is making it easier for people to recognize their surroundings. How does it work? You simply point the phone’s rear camera at whatever you want to identify and it speaks what it sees. The app can identify one object after another as the user moves the phone around and it doesn’t require picture taking.The app can be helpful not only to people with impaired vision but also to the ones trying to learn a new language.

Aipoly cofounder Simon Edwardsson says it recognizes images by using deep learning, which is a machine-learning technique inspired by studies of the brain. This is the same technology used by Facebook for recognizing faces and Google for searching images. The app breaks down the image into different characteristics like lines, patterns, curves, etc. and uses them to determine the likelihood of that image to be a specific object. The app works fine for objects around the office. So far it can recognize around 1,000 objects, which is more than enough.

Banknote-reader (b-reader)
The banknote reader is a device that helps the visually impaired to recognize money. The banknote goes into the b-note holder for scanning and recognition (orientation doesn’t really matter), it gets photographed and sent securely to the cloud. There an Imagga-trained custom classifier recognizes the nominal value and returns the information to the b-note device. Then it plays a pre-recorded .mp3 file with the value if it is recognized. The project is part of TOM (Tikkun Olam Makers), a global movement of communities connecting makers, designers, engineers and developers with people with disabilities to develop technological solutions for everyday challenges. On the web platform, you can find full specs of the b-note prototype, including building instructions and camera code used for calling Images API, so that you can make a device like it for around 100 Euro or 115 USD.

This is a combination of a Smartphone and advanced “artificial vision” software to create a helpful electronic assistant for anyone who is visually impaired or blind. It can be used to automatically scan and identify objects like money, packaged goods, DVDs, CDs, medication bottles, and even landmarks. All it takes is to point the device video camera at the object and the device pronounces the name quickly and clearly. It can be taught to identify all the objects and landmarks around you. With a little extra help, the LookTel can be a helpful assistant. It also incorporates a text reader which allows users to get access to print media.

Seeing AI
This is a smartphone app that uses computer vision to describe the world and is created by Microsoft. Once the app is downloaded, the user can point the camera at a person and it will announce who the person is and how they are feeling. The app also works with products. It is done by artificial intelligence running locally on the phone. So far the app is available for free in the US for iOS. It is unclear when the rest of the world and Android users will be able to download it.

The app works well for recognizing familiar people and household products (scanning barcodes). It can also read and scan documents and recognize US currency. This is not a small feat because the dollar bills are basically the same size and color, regardless of their value, so spotting the difference is sometimes difficult for the visually impaired. The app is using neural networks to identify objects, which is the same technology used for self-driving cars, drones, and others. The most basic functions take place on the phone itself, however most features require a connection.

Next  Challenges for Full Adoption

Facebook users upload more than 350 million photos a day. Websites are relying mostly on images and less on the text. Sharing visuals has become a major part of the online experience. So using screen readers and screen magnifiers on mobile and desktop platforms help the visually impaired. However, more efforts need to be put to make the web more accessible through design guidelines, designer awareness, and evaluation techniques.

The most difficult challenge ahead is the evaluation of the effectiveness of image processing. It needs to be held ultimately to the same standards as other clinical research in low vision. Image processing algorithms need to be tailored specifically to disease entities and be available on a variety of displays, including tablets. This field of research has the potential to deliver great benefits to a large number of people in short period of time.

Batch Image Processing From Local Folder Using Imagga API

Batch Upload of Photos for Image Recognition

This blog post is part of series on How-Tos for those of you who are not quite experienced and need a bit of help to set up and use properly our powerful image recognition APIs.

In this one we will help you to batch process (using our Tagging or Color extraction API) a whole folder of photos, that reside on your local computer. To make that possible we’ve written a short script in the programming language Python:

Feel free to reuse or modify it. Here’s a short explanation what it does. The script requires the Python package, which you can install using this guide.

It uses requests’ HTTPBasicAuth to initialize a Basic authentication used in Imagga’s API from a given API_KEY and API_SECRET which you have to manually set in the first lines of the script.

There are three main functions in the script - upload_image, tag_image, extract_colors.

    • upload_image(image_path) - uploads your file to our API using the content endpoint, the argument image_path is the path to the file in your local file system. The function returns the content id associated with the image.
  • tag_image(image, content_id=False, verbose=False, language='en') - the function tags a given image using Imagga’s Tagging API. You can provide an image url or a content id (from upload_image) to the ‘image’ argument but you will also have to set content_id=True. By setting the verbose argument to True, the returned tags will also contain their origin (whether it is coming from machine learning recognition or from additional analysis). The last parameter is ‘language’ if you want your output tags to be translated in one of Imagga’s supported 50 (+1) languages. You can find the supported languages from here -
  • extract_colors(image, content_id=False) - using this function you can extract colors from your image using our Color Extraction API. Just like the tag_image function, you can provide an image URL or a content id (by also setting content_id argument to True).

Script usage:

Note: You need to install the Python package requests in order to use the script. You can find installation notes here.

You have to manually set the API_KEY and API_SECRET variables found in the first lines of the script by replacing YOUR_API_KEY and YOUR_API_SECRET with your API key and secret.

Usage (in your terminal or CMD):

python <input_folder> <output_folder> --language=<language> --verbose=<verbose> --merged-output=<merged_output> --include-colors=<include_colors>

The script has two required - <input_folder>, <output_folder> and four optional arguments - <language>, <verbose>, <merged_output>, <include_colors>.

  • <input_folder> - required, the input folder containing the images you would like to tag.
  • <output_folder> - required, the output folder where the tagging JSON response will be saved.
  • <language> - optional, default: en, the output tags will be translated in the given language (a list of supported languages can be found here:
  • <verbose> - optional, default: False, if True the output tags will contain an origin key (whether it is coming from machine learning recognition or from additional analysis)
  • <include_colors> - optional, default: False, if True the output will also contain color extraction results for each image.
  • <merged_output> - optional, default: False, if True the output will be merged in a JSON single file, otherwise - separate JSON files for each image.

Imagga partners with Blitline to jointly offer Smart Cropping

We are excited to announce that starting today we are partnering with Blitline, one of the best and most lightweight and easy to integrate image processing services in the cloud!

Blitline& Imagga

Our cooperation starts with the opportunity for Blitline users to take advantage of our smart-cropping, as applied in our cropping API and cropping tool The guys at Blitline have produced a very easy to understand example why Imagga’s smart cropping is better than just center cropping:

How Imagga smart cropping works

Imagga Smart Cropping as explained by Blitline

Funny enough, the idea for the cooperation came a month ago from an existing user of Blitline who approached us and asked if we can provide them with the same seamless integration that Blitline offers for regular cropping, but with our smart cropping, or ideally – can we offer it via Blitline? No sooner said than done! We got in contact and things simply worked out.

Now Blitline users who subscribe for the special Blitline + Imagga plan have access to the imagga_smart_crop function for their image processing pipeline. The pricing sticks to the pay-as-you-go model (per cropped image) plus a very low monthly subscription fee.

Blitline Imagga Pricng Plan

Blitline + Imagga Pricing Plan

We do believe this is going to be a great example of co-opetition!