Installing and configuring Autotagging

November 14, 2023

The Autotagging module enables you to use Amazon Rekognition services to analyze and automatically tag images in your sites. For example, Rekognition can detect labels in images. You can configure the module to apply tags to images when content editors add them to your site or to allow editors to tag images manually. You can also specify settings such as the minimum confidence level needed to add a tag and the maximum number of tags to add to a single image. If you already have images in your site, you can use the GraphQL API to analyze those images.

Note: To understand how content editors use Autotagging, see Autotagging your images.

Obtaining credentials for the Amazon Rekognition service

To use the automated tags module, you require credentials to access the Amazon image rekognition API. The module leverages the labels API described in Amazon documentation on detecting objects and scenes.

To get credentials for accessing the API:

  1. Sign up for an AWS account. For more information, see the Sign up for AWS Amazon documentation.
  2. Create an Identity and Access Management (IAM) user so that you can access the rekognition API. For more information, see Create an IAM user.
    Note: At a minimum, the IAM user requires the AmazonRekognitionReadOnlyAccess right to access the API. The user that you create should have programmatic access. Select the appropriate checkbox when you create the IAM user.
  3. After creating the user, download the .csv file that contains information related to the user, including the accessKey and secretKey needed to configure the module.

Installing the Autotagging  module

Before using autotagging, you must add the module to Jahia and enable it. The Autotagging module is available on the Jahia store

For more information on enabling a module, see Installing a module tutorial.

Configuring the Autotagging module

Next you create a config file to specify settings for the module.

To configure the Autotagging module:

  1. Create a file named org.jahia.modules.automatedtags.service.impl.AutomatedTagServiceImpl.cfg in your digital-factory-data/karaf/etc folder on your server. 
  2. Add the following keys to the config file that you can find from your Amazon account:
    automated-tags.accessKey
    Access key ID 
    automated-tags.secretKey
    Secret access key
    Automated-tags.endpoint
    endpoint of the rekognition API
    Automated-tags.region
    Region for billing
  3. Next, add Jahia configuration keys:
    automated-tags.minConfidence
    The minimum confidence level that Jahia requires to add the tag needs to the image. We recommend that you set it to 95.
    automated-tags.maxTagsAdded
    The maximum number of labels returned, in order of highest confidence level. We recommend that you set it to 6.
    automated-tags.tagImageOnUpload
    Whether to automatically tag images on upload. This is true by default.
  4. Save your change to the config file.

Note: If you don't have access to the Jahia file system to create the cfg file, you can create it using the karaf REST API. 

curl -s --user login:mypassword -X POST https://yourjahia.com/modules/api/commands -d "\
    config:edit org.jahia.modules.automatedtags.service.impl.AutomatedTagServiceImpl; \
    config:property-set automated-tags.accessKey yourAccessKey; \
    config:property-set automated-tags.secretKey yourSecretKey; \
    config:property-set automated-tags.endpoint https://rekognition.eu-central-1.amazonaws.com; \
    config:property-set automated-tags.region eu-central-1; \
    config:property-set automated-tags.tagImageOnUpload true; \
      config:update;"

Automatically tagging many images at once

If you have many images in your system and want to tag them before enabling autotagging, then you can use the GraphQL API to trigger a job. This job automatically tags all images defined by your JCR query. Use the tagImage mutation to automatically tag all images (jnt:file with jmix:image). This launches a job that processes nodes in batches of 100.

For example, this JCR query automatically tags images in the digitall site.

mutation jcr {
  mutateNodesByQuery(query:"select * from [jmix:image] as im where isdescendantnode(im, '/sites/digitall')") {
    awsRecognition {
        tagImage
    }
  }
}