### Response Example for Download Image (Search + Compression) Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Example of a successful response after downloading an image using search mode and applying compression. It includes details about the original and compressed sizes, compression ratio, and quality settings. ```json { "query": "mountain sunset", "imageId": 12345, "width": 1920, "height": 1080, "imageSize": 0, "user": "John Doe", "tags": "mountain sunset", "inputPath": "...", "outputPath": "./images/mountain.webp", "originalSize": 500000, "compressedSize": 80000, "compressionRatio": 84.00, "success": true, "iterations": 1, "qualitySteps": [85], "finalQuality": 85, "exceededTarget": false } ``` -------------------------------- ### Example Usage of Get Acknowledgement Tool Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/06-get-acknowledgement.md Demonstrates how to call the get_acknowledgement tool with an empty arguments object, as no parameters are required. ```json { "tool": "get_acknowledgement", "arguments": {} } ``` -------------------------------- ### Install image-processor-mcp via npm Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/07-credits-installation.md Use this command to install the package from npm. Ensure you have Node.js 18 or higher and npm installed. ```bash npm install image-processor-mcp ``` -------------------------------- ### Sync Filenames Dry Run Example Output Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Example output demonstrating a dry run of the sync_filenames function. It indicates that no files were modified and provides a summary of the operation, including the mapping source, files scanned, and replacements found. ```text Dry run — no files were modified. Mapping source: .image-processor-mcp/mappings/mappings-2026-05-29-15-30-00.json Files scanned: 42 Files with matches: 3 Total replacements: 12 --- Matches --- [src/components/Header.tsx] "logo.png" → "logo.webp" (5x) Preview: ... context lines ... Line 15:23 "logo.png" → "logo.webp" ... and 3 more (see report) Report saved to: .image-processor-mcp/syncs/dry-run/sync-report-2026-05-29-15-31-00.md ``` -------------------------------- ### Sync Report Example Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/04-sync-filenames.md Illustrates the structure and content of a generated sync report, including dry run status, file statistics, and detailed match information. ```text Dry run — no files were modified. Mapping source: .image-processor-mcp/mappings/mappings-2026-05-29-15-30-00.json Files scanned: 42 Files with matches: 3 Total replacements: 12 --- Matches --- [src/components/Header.tsx] "logo.png" → "logo.webp" (5x) Preview: ... context lines ... Line 15:23 "logo.png" → "logo.webp" Line 42:8 "logo.png" → "logo.webp" ... and 3 more (see report) Report saved to: .image-processor-mcp/syncs/dry-run/sync-report-2026-05-29-15-31-00.md ``` -------------------------------- ### JSON Response Example (with Rectangle and Blocks) Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Response including rectangle details and detailed text blocks when specified in the request. ```json { "success": true, "text": "Region-specific text", "confidence": 88.3, "words": 12, "language": "eng", "durationMs": 890, "preprocessed": true, "rectangle": { "top": 50, "left": 0, "width": 400, "height": 150 }, "blocks": [ ... ] } ``` -------------------------------- ### Internal Implementation of Get Acknowledgement Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/06-get-acknowledgement.md Illustrates the synchronous process of building the markdown documentation string by interpolating values from various configuration sources. ```typescript ToolController.handleGetAcknowledgement() └─ Synchronous — no abort signal, no async operations └─ Builds markdown string via template literals └─ Interpolates values from: ├─ DEFAULTS (all default values) ├─ CONFIG_DESCRIPTIONS (parameter descriptions) ├─ SUPPORTED_EXTENSIONS (input format list) ├─ INPUT_EXTENSION_DESCRIPTIONS (format descriptions) ├─ SUPPORTED_OUTPUT_FORMATS (output format list) ├─ OUTPUT_FORMAT_DESCRIPTIONS (output format descriptions) ├─ RESTRICTED_EXTENSIONS (SVG) ├─ DEFAULT_EXTENSIONS (sync scan extensions) ├─ DEFAULT_EXCLUDE_DIRS (sync scan exclude dirs) └─ APP_CONFIG (name, version) ``` -------------------------------- ### Run image-processor-mcp Directly Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/07-credits-installation.md Execute this command to start the MCP server directly. It will run on stdio, outputting diagnostic messages to stderr and communicating with the MCP client via stdin/stdout. ```bash npx -y image-processor-mcp ``` -------------------------------- ### Response Example for compress_directory Tool Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/03-compress-directory.md This JSON object represents a successful response from the compress_directory tool, detailing the outcome of the compression process, including file counts, sizes, and paths to generated reports. ```json { "success": true, "totalFiles": 10, "successful": 9, "failed": 1, "totalOriginalSize": 5000000, "totalCompressedSize": 1200000, "overallReduction": 76.00, "durationMs": 5432, "reportPath": ".image-processor-mcp/reports/scan-report-2026-05-29-15-30-00.md", "mappingsPath": ".image-processor-mcp/mappings/mappings-2026-05-29-15-30-00.json" } ``` -------------------------------- ### JSON Response Example (Basic) Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md A typical JSON response when extracting text with default settings. ```json { "success": true, "text": "Extracted text content here...", "confidence": 92.5, "words": 42, "language": "eng", "durationMs": 1234, "preprocessed": true } ``` -------------------------------- ### Response Example for Image Compression Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/02-compress-image.md Illustrates the structure of the JSON response returned after an image compression operation, including details on original and compressed sizes, compression ratio, and success status. ```json { "inputPath": "./input/photo.jpg", "outputPath": "./output/photo.webp", "originalSize": 500000, "compressedSize": 80000, "compressionRatio": 84.00, "success": true, "iterations": 1, "qualitySteps": [85], "finalQuality": 85, "exceededTarget": false } ``` -------------------------------- ### Get Acknowledgement Response Format Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/06-get-acknowledgement.md Defines the structure of the response from the get_acknowledgement tool, which contains the generated markdown documentation. ```json { "content": [{ "type": "text", "text": "" }] } ``` -------------------------------- ### Extract Text with Default Parameters Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Extracts text using default settings (English language, text output, preprocessing enabled). Provide the image path to start. ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png" }); console.log(result.text); ``` -------------------------------- ### Handle Get Acknowledgement in TypeScript Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md This function is used to retrieve comprehensive documentation of all tools, defaults, formats, and environment variables. It is synchronous and does not accept an abort signal or operate asynchronously. ```typescript ToolController.handleGetAcknowledgement() // Synchronous — no abort signal, no async // Returns { content: [{ type: 'text', text: markdown }] } ``` -------------------------------- ### OCR Response Example (text format) Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md This JSON structure represents the successful extraction of text from an image. It includes the extracted text, confidence score, word count, language used, and processing duration. ```json { "success": true, "text": "Extracted text content", "confidence": 92.5, "words": 42, "language": "eng", "durationMs": 1234, "preprocessed": true } ``` -------------------------------- ### Image Compression Algorithm Steps Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Outlines the sequential steps involved in the core compression algorithm, including reading metadata, resizing, and iterative quality reduction for recursive compression. ```text 1. Read original size + image metadata (sharp) 2. Compute resize: - Explicit w/h? → use those - Exceeds maxDimension? → scale proportionally - Otherwise → no resize 3. Loop: - sharp pipeline → apply format with quality - If input === output → buffer (safe in-place) - Else → write to file - If recursive + over target + above floor → reduce quality, loop - Else → break 4. Return CompressionResult ``` -------------------------------- ### Output Path Algorithm Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Defines the algorithm for generating output paths, including directory normalization, file naming, and extension replacement. ```text relativePath = inputDir → inputFile difference 1. Dir naming enabled → normalize each directory component 2. File naming enabled → normalize basename 3. Replace extension with .{outputFormat} 4. Prepend outputDir ``` -------------------------------- ### Download Image Data Flow Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Illustrates the data flow for the `download_image` function, from request handling to image compression and final output. ```text Request → type guard → Controller ├─ Search mode? → Pexels API → first hit URL └─ URL mode? → use directly ↓ axios.get(url, arraybuffer, 30s timeout) ↓ Write to temp file → check compression params ├─ YES → ImageService.compressImage → clean temp → return result └─ NO → move to final path → return success ``` -------------------------------- ### Configure MCP Server for Claude Desktop Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/07-credits-installation.md Add this JSON configuration to your `claude_desktop_config.json` to integrate the image-processor-mcp as an MCP server. The Pexels API key is optional and used for keyword-based image search. ```json { "mcpServers": { "image-processor-mcp": { "command": "npx", "args": ["-y", "image-processor-mcp"], "env": { "IMAGE_SEARCH_API_KEY": "your_pexels_api_key_here" } } } } ``` -------------------------------- ### get_acknowledgement Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Retrieves comprehensive documentation of all tools, defaults, formats, and environment variables used by the image processor. This endpoint is synchronous and does not accept any parameters. ```APIDOC ## get_acknowledgement ### Description Returns comprehensive documentation of all tools, defaults, formats, and environment variables. ### Method GET ### Endpoint /acknowledgement ### Parameters **None** — empty input schema. ### Response #### Success Response (200) - **content** (array) - An array containing objects with `type` and `text` properties, where `text` is a markdown document detailing the system's configuration. ### Response Example ```json { "content": [ { "type": "text", "text": "# Image Processor Documentation\n\n## Tools\n... (details about tools)\n\n## Configuration Defaults\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| quality | `85` | Compression quality for lossy formats (1–100) | | ... | ... | ... | " } ] } ``` ### Implementation Notes This endpoint is implemented via `ToolController.handleGetAcknowledgement()` and is synchronous. ``` -------------------------------- ### Data Flow for Sync Filenames Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Illustrates the data flow from request to file modification or preview during the filename synchronization process. It details how mappings are read, files are scanned, and replacements are made. ```text Request → type guard → Controller ├─ mappingFilePath? │ YES → ReferenceService.readMappingFile → validate against report │ NO → use inline mappings ├─ dryRun = args.dryRun !== false ├─ ReferenceService.scanReferences: │ ├─ Collect files recursively (filtered by extension, excluding dirs) │ ├─ For each file: │ │ ├─ For each mapping: │ │ │ ├─ Regex-escape oldFileName, count occurrences │ │ │ ├─ Build line-by-line details │ │ │ ├─ Build preview (3 lines context) │ │ │ └─ If !dryRun: replace in content │ │ └─ If modified: write file │ └─ Return UpdateRefResult └─ ReportService.generateSyncReport → .image-processor-mcp/syncs/ ``` -------------------------------- ### Inline Mapping Configuration Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/04-sync-filenames.md Use this configuration as a fallback when direct mapping objects are provided. Specify the root directory to scan and an array of `{oldFileName, newFileName}` objects. ```json { "scanDir": "./src", "mappings": [ { "oldFileName": "logo.png", "newFileName": "logo.webp" }, { "oldFileName": "banner.jpg", "newFileName": "banner.avif" } ], "dryRun": true } ``` -------------------------------- ### Compress Image with Options Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/02-compress-image.md Compresses an image to WebP format with specified quality and dimensions. Ensure the output directory exists before calling. ```typescript import { compressImage } from "@/lib/image-processor-mcp/compress-image"; const inputPath = "./input/photo.jpg"; const outputPath = "./output/photo.webp"; await compressImage(inputPath, outputPath, { outputFormat: "webp", quality: 80, width: 500, height: 300, }); ``` -------------------------------- ### Filename Normalization Logic Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Explains the process of normalizing filenames by replacing characters, collapsing underscores, trimming edges, and applying case conversion. ```text Replace each char → '_', collapse multiple '_', trim edges, apply case ``` -------------------------------- ### Data Flow for Image Compression Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Illustrates the data flow from request to file processing and report generation for image compression. ```text Request → type guard → Controller ├─ Validate input directory exists ├─ Apply defaults, build FileNamingOptions ├─ Scan all image files (recursive) ├─ Filter out SVG (restricted) ├─ For each file: │ ├─ Compute output path (preserves structure, normalizes, changes ext) │ └─ Run ImageService.compressImage ├─ Generate report (.image-processor-mcp/reports/) └─ Generate mappings JSON (.image-processor-mcp/mappings/) ``` -------------------------------- ### File-based Mapping Configuration Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/04-sync-filenames.md Use this configuration when you have a `mappings-{timestamp}.json` file generated by `compress_directory`. Specify the root directory to scan and the path to the mapping file. ```json { "scanDir": "./src", "mappingFilePath": ".image-processor-mcp/mappings/mappings-2026-05-29-15-30-00.json", "dryRun": true } ``` -------------------------------- ### Generated Files Structure Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Shows the directory structure for generated report and mappings files. ```text .image-processor-mcp/ ├── reports/scan-report-{timestamp}.md └── mappings/mappings-{timestamp}.json ``` -------------------------------- ### Batch Compress Directory Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Compresses all images in a directory recursively, preserving folder structure. Generates a report and mappings file. ```markdown ## 3. compress_directory Batch compress all images in a directory recursively, preserving folder structure. Generates report + mappings. ``` -------------------------------- ### Generated Files for Sync Reports Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Shows the file paths for generated synchronization reports, differentiating between live updates and dry-run previews. The timestamp in the filename is crucial for linking reports to specific mapping files. ```text .image-processor-mcp/syncs/sync-report-{timestamp}.md (live) .image-processor-mcp/syncs/dry-run/sync-report-{timestamp}.md (dry-run) ``` -------------------------------- ### Image Download Response (Search + Compression) Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/01-download-image.md This JSON structure represents the response when an image is found via search and then compressed. It includes details about the search query, image metadata, compression results, and success status. ```json { "query": "mountain sunset", "imageId": 12345, "width": 1920, "height": 1080, "imageSize": 0, "user": "John Doe", "tags": "mountain sunset landscape", "inputPath": "...", "outputPath": "./images/mountain.webp", "originalSize": 500000, "compressedSize": 80000, "compressionRatio": 84.00, "success": true, "iterations": 1, "qualitySteps": [85], "finalQuality": 85, "exceededTarget": false } ``` -------------------------------- ### Image Download Response (URL Only, No Compression) Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/01-download-image.md This JSON structure represents the response when an image is downloaded directly from a URL without any compression. It confirms the success of the operation and provides the output path and file size. ```json { "success": true, "outputPath": "./images/photo.jpg", "fileSize": 500000 } ``` -------------------------------- ### compress_image Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/README.md Compress or convert a single image with full control over quality, dimensions, format, and recursive compression. ```APIDOC ## compress_image ### Description Compress or convert a single image with full control over quality, dimensions, format, and recursive compression. ### Parameters #### Path Parameters - `inputPath` (string) - Required - Source image path - `outputPath` (string) - Required - Destination path #### Query Parameters - `outputFormat` (string) - Optional - Default: `webp` - Output format - `quality` (number) - Optional - Default: `85` - 1–100 - `lossless` (boolean) - Optional - Default: `false` - Lossless mode - `effort` (number) - Optional - Default: `6` - CPU effort 0–6 - `width` (number) - Optional - Target width - `height` (number) - Optional - Target height - `maxDimension` (number) - Optional - Default: `2000` - Auto-resize threshold - `recursiveCompress` (boolean) - Optional - Default: `false` - Iterative targeting - `expectedSizeKB` (number) - Optional - Default: `100` - Target KB - `qualityStepDown` (number) - Optional - Default: `10` - Per-iteration decrease - `minimumQualityFloor` (number) - Optional - Default: `10` - Minimum quality ### Response Example ```json { "inputPath": "./input/photo.jpg", "outputPath": "./output/photo.webp", "originalSize": 500000, "compressedSize": 80000, "compressionRatio": 84.00, "success": true, "iterations": 1, "qualitySteps": [85], "finalQuality": 85, "exceededTarget": false } ``` ### Edge Cases - **In-place compression** (same path): Buffer-based to avoid corruption - **Missing input file**: `success: false` with error - **Unknown format**: Falls back to WebP - **Recursion floor**: Stops when quality can't decrease further - **Abort**: Returns partial result with `success: false` ``` -------------------------------- ### Image Compression with Abort Signal Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/02-compress-image.md Compresses an image and allows the operation to be cancelled using an AbortSignal. If cancelled mid-recursion, it returns a partial result with an error message. ```typescript import { compressImage } from "@/lib/image-processor-mcp/compress-image"; const controller = new AbortController(); const signal = controller.signal; compressImage( "./input/very_large.tiff", "./output/very_large_compressed.avif", { lossless: true, signal: signal, // Pass the abort signal } ).catch((error) => { if (error.name === 'AbortError') { console.log('Image compression was cancelled.'); } else { console.error('An error occurred:', error); } }); // To cancel the operation: // controller.abort(); ``` -------------------------------- ### In-place Image Compression Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/02-compress-image.md Compresses an image and saves it to the same path, overwriting the original. This is handled safely using an internal buffer to prevent data corruption. ```typescript import { compressImage } from "@/lib/image-processor-mcp/compress-image"; await compressImage( "./input/photo.jpg", "./input/photo.jpg", // Same input and output path { quality: 75, outputFormat: "jpeg", } ); ``` -------------------------------- ### Recursive Image Compression Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/02-compress-image.md Recursively compresses an image, reducing quality iteratively until it meets the expected size in KB. The minimum quality floor prevents excessive degradation. ```typescript import { compressImage } from "@/lib/image-processor-mcp/compress-image"; await compressImage( "./input/large.png", "./output/large_compressed.png", { recursiveCompress: true, expectedSizeKB: 50, qualityStepDown: 5, minimumQualityFloor: 20, } ); ``` -------------------------------- ### Extract Text with Specific Language and Output Format Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Specify a language (e.g., French) and an output format (e.g., JSON blocks with positions). ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png", language: "fra", outputFormat: "blocks" }); console.log(result.blocks); ``` -------------------------------- ### Extract Text with Preprocessing Disabled Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Disable automatic image preprocessing (grayscale, auto-rotate, resolution normalization) if you intend to handle these steps manually. ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png", preprocess: false }); console.log(result.text); ``` -------------------------------- ### Extract Text with Multiple Languages Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Process an image containing text in multiple languages by combining language codes with a '+'. ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png", language: "eng+chi_sim" }); console.log(result.text); ``` -------------------------------- ### Generated Mappings JSON Structure Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/03-compress-directory.md This JSON structure is generated when at least one successful compression occurs and a timestamp can be extracted from the report filename. It maps old filenames to new filenames. ```json { "generatedAt": "2026-05-29T15:30:00.000Z", "tool": "compress_directory", "mappings": [ { "oldFileName": "photo.png", "newFileName": "photo.webp" }, { "oldFileName": "banner.jpg", "newFileName": "banner.avif" } ] } ``` -------------------------------- ### Extract Text with TSV Output Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Obtain OCR results in a Tab-Separated Values (TSV) format, suitable for tabular data processing. ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png", outputFormat: "tsv" }); console.log(result.tsv); ``` -------------------------------- ### Extract Text with HOCR Output Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Generate OCR results in an HTML-like structured markup format (hOCR) for detailed text and layout information. ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png", outputFormat: "hocr" }); console.log(result.hocr); ``` -------------------------------- ### Extract Text from a Specific Region Source: https://github.com/pansuriyadhvanil/image-processor-mcp/blob/main/docs/05-extract-text.md Limit OCR processing to a defined rectangular area within the image. Coordinates are relative to the image's top-left corner. ```javascript import { extractText } from "@/modules/ocr/extract-text"; const result = await extractText({ imagePath: "/path/to/your/image.png", rectangle: { top: 50, left: 0, width: 400, height: 150 } }); console.log(result.text); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.