OCR and image reports

Image moderation assesses visual content and readable text. Enable the optional OCR processing feature with processingOptions.features.ocr.enabled: true per upload to extract and moderate text separately. The text moderation result contributes to the image’s combined report. Use it for screenshots, signs and memes; poor legibility or layout can still cause recognition errors.

{
  "processingOptions": {
    "features": {
      "ocr": { "enabled": true }
    }
  }
}

When OCR is disabled

With OCR off (the default, when the request doesn't turn it on), the image is evaluated directly, including text the visual model can read. Image qualifiers carry the same Some and All scores as text, so allowances and restrictions apply to images as they do to text. For clearly readable written content, the category boundaries match text moderation, but the scores need not match numerically: image recognition, layout, visual evidence and model uncertainty can change the result. Enable OCR to assess extracted text separately as well.

When OCR is enabled

With processingOptions.features.ocr.enabled set to true, non-empty extracted text receives an additional normal text moderation pass. Its result is merged into the image report before the project's policy is applied. No separate text asset is created.

The extracted text is kept only when the upload sets keepContentAfterProcessing; otherwise content.extractedText is null once processing finishes. When it is kept, retrieve the image to read content.extractedText, or open its extracted-text section in the portal. Small text is inline as { "type": "string", "content": "…" }; larger text is a document reference with type: "document" and an id. The API doesn't return the text while the image is under a safety or copyright hold. Removing or purging the image's content also removes its extracted text. The combined classification.moderation remains available after content removal. Reclassification replaces the image's extracted text.

OCR extraction and moderation are separately metered: the OCR request increments OCR usage on the image, and non-empty extracted text incurs normal text-moderation tokens on the image. Combining the two reports does not run or bill text moderation again.

Merged reports combine the two results field by field:

FieldMerged result
Parent category scoreThe higher evaluated score.
Qualifier Some scoreThe highest supported score across the image and the extracted text.
Qualifier All scoreThe lowest supported score, capped by Some. Missing All evidence stays unavailable and can't establish coverage.
Parent evaluation statusevaluated if either report evaluated it directly, partial if only a narrower signal was evaluated.

Category evidence below 0.1 doesn't contribute to qualifier merging. Because qualifiers are merged this way, an allowance that covers the visual content can't exempt a separate current threat in the extracted text, and the reverse also holds.

If OCR returns no non-whitespace text, content.extractedText is null and only the direct image classification result is used. If OCR extraction or moderation of the extracted text fails, image processing fails: CalmLens doesn't replace failed text moderation with an allowed text result or a completed visual-only decision.

Text regions and redaction

OCR also records where text sits in the image, in classification.ocr. When OCR ran, its status is evaluated and textRegions holds a box per paragraph, and a box around each email address, phone number, payment card number, IBAN and US social security number it reads, marked personalInformation: true. Boxes are fractions of the image width and height, and textRegions is empty for an image without text. When OCR couldn't run on the image, status is not-evaluated with a reason: not-supported or unavailable. classification.ocr is null when OCR wasn't requested.

Serve a redacted copy with the redact transform, which blurs those regions before any other transform option applies:

  • redact.personalInformation blurs only the personal information.
  • redact.text blurs every paragraph.

For example, /rendered/redact.personalInformation,width=800 serves a resized copy with contact details and account numbers blurred. Redaction applies before the other options of the same transform, on the full image, so it lines up with the regions OCR found even when the transform resizes or crops. An image uploaded without OCR has no regions and is served unchanged. See Lenses.

Link detection finds links in every image by default; set processingOptions.features.linkDetection.enabled to false to skip it for an upload. It decodes up to five QR codes and lists them in classification.linkDetection.qrCodes, each with its contents and position. What a QR code says is moderated as text and merged into the image report like OCR text, so a QR code linking to harmful content or carrying abusive text affects the decision.

classification.linkDetection.links lists the web links found, with the source of each: qr-code, or text for links in the OCR text when OCR is also on. Links are listed for your own checks, such as against a list of known scam domains; link detection itself does not visit them. Link detection is free; moderating QR code text bills text-moderation tokens like OCR text.

When your policy acts on links, link safety follows these links' redirects and checks every address on the way. An image uploaded with link detection off has no QR code links checked.

Last updated

Signing in

Signing out

Cookies on CalmLens

We use essential cookies for sign-in and security. With your permission, functional cookies remember your preferences and Google Analytics measures website use and signups. Optional ad measurement cookies link Google ad clicks to signups. Personalised advertising stays off. Manage cookies