# Process Image — OCRSpace

> Submits an image file for OCR processing using OCR.space. See the documentation

- Key: `ocrspace-process-image`
- Type: Action (Write)
- Version: 0.1.4
- App: OCRSpace (`ocrspace`) — https://pipedream.com/apps/ocrspace.md
- This page (HTML): https://pipedream.com/apps/ocrspace/actions/process-image
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/ocrspace/actions/process-image/process-image.mjs

## Description

Submits an image file for OCR processing using OCR.space. [See the documentation](https://ocr.space/ocrapi)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `language` | `string` | No | Language setting for image OCR processing. |
| `isOverlayRequired` | `boolean` | No | If true, returns the coordinates of the bounding boxes for each word. If false, the OCR'ed text is returned only as a text block (this makes the JSON response smaller). Overlay data can be used, for example, to show text over the image. |
| `detectOrientation` | `boolean` | No | If set to true, the api autorotates the image correctly and sets the TextOrientation parameter in the JSON response. If the image is not rotated, then TextOrientation=0, otherwise it is the degree of the rotation, e. g. "270". |
| `scale` | `boolean` | No | If set to true, the api does some internal upscaling. This can improve the OCR result significantly, especially for low-resolution PDF scans. Note that the front page demo uses scale=true, but the API uses scale=false by default. See also this OCR forum post. |
| `isTable` | `boolean` | No | If set to true, the OCR logic makes sure that the parsed text result is always returned line by line. This switch is recommended for table OCR, receipt OCR, invoice processing and all other type of input documents that have a table like structure. |
| `ocrEngine` | `string` | No | Engine 1 is default. See OCR Engines. |
| `file` | `string` | Yes | The file to process. Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.jpg) |
| `filetype` | `string` | No | Overwrites the automatic file type detection based on content-type. Supported image file formats are png, jpg (jpeg), gif, tif (tiff) and bmp. For document ocr, the api supports the Adobe PDF format. Multi-page TIFF files are supported. |
| `syncDir` | `dir` | No | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "ocrspace",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "ocrspace-process-image",
  arguments: {
    language: "Language",
    isOverlayRequired: true,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "ocrspace-process-image",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    ocrspace: { authProvisionId: "apn_xxxxxxx" },
    language: "Language",
    isOverlayRequired: true,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "ocrspace-process-image",
    "configured_props": {
      "ocrspace": { "authProvisionId": "apn_xxxxxxx" },
      "language": "Language",
      "isOverlayRequired": true
    }
  }'
```

---

- App: https://pipedream.com/apps/ocrspace.md · All apps: https://pipedream.com/apps
