RAP Logo
Blocks ReferenceComputer vision

Tiff Utils

Split and process multi-page TIFF files with utility functions for TIFF image manipulation.

Tiff Utils Block

The Tiff Utils block is designed for splitting TIFF files and provides a simple interface for processing multi-page TIFF images. It offers essential utilities for working with TIFF format images, particularly useful for handling multi-page documents and image sequences.

Overview

The Tiff Utils block provides comprehensive TIFF file processing capabilities, including splitting multi-page TIFF files into individual pages, extracting specific pages, and basic TIFF manipulation operations. It's essential for document processing workflows that work with TIFF format files.

Configuration Options

Processing Mode

Choose the type of TIFF operation to perform:

  • Split TIFF: Split multi-page TIFF files into individual pages
  • Extract Pages: Extract specific pages from a TIFF file
  • Convert Format: Convert TIFF files to other image formats
  • Page Information: Get information about TIFF file structure

Input Configuration

TIFF File Path

  • Property: msg.payload.tiff_path
  • Type: string
  • Description: Specify the relative path of the TIFF file on shared storage
  • Example: "documents/multi_page.tiff" or "scans/document.tif"

Page Range (Optional)

  • Property: msg.payload.page_range
  • Type: string or array
  • Description: Specify which pages to process
  • Examples:
    • "1-5" - Pages 1 through 5
    • [1, 3, 5] - Specific pages 1, 3, and 5
    • "all" - All pages (default)

Output Configuration

Output Format

  • Split Pages: Individual image files for each page
  • Combined: Single output with page information
  • Metadata: TIFF file information and structure

Output Directory

  • Property: msg.payload.output_dir
  • Type: string
  • Description: Directory to save split pages
  • Default: Same directory as input file

Use Cases

Document Processing

Split multi-page scanned documents:

Multi-page TIFF → Tiff Utils (split) → Individual pages → OCR processing

Archive Management

Extract specific pages from archived TIFF files:

Archive TIFF → Tiff Utils (extract pages 1-3) → Selected pages → Processing

Format Conversion

Convert TIFF files to other formats:

TIFF file → Tiff Utils (convert) → PNG/JPEG files → Further processing

Batch Processing

Process multiple TIFF files:

TIFF batch → Tiff Utils (split all) → Individual pages → Batch OCR

Common Patterns

Basic TIFF Splitting

// Configuration
// Processing Mode: Split TIFF
// Page Range: All pages

// Input message:
{
  "payload": {
    "tiff_path": "documents/contract.tiff",
    "output_dir": "split_pages/"
  }
}

// Example flow:
// inject → Tiff Utils → debug (split results)

Extract Specific Pages

// Configuration
// Processing Mode: Extract Pages
// Page Range: [1, 3, 5]

// Input message:
{
  "payload": {
    "tiff_path": "scans/report.tiff",
    "page_range": [1, 3, 5],
    "output_dir": "selected_pages/"
  }
}

// Example flow:
// inject → Tiff Utils → debug (extracted pages)

Page Range Processing

// Configuration
// Processing Mode: Split TIFF
// Page Range: "2-10"

// Input message:
{
  "payload": {
    "tiff_path": "documents/manual.tiff",
    "page_range": "2-10"
  }
}

// Example flow:
// inject → Tiff Utils → debug (pages 2-10)

Advanced Features

TIFF Metadata Extraction

Get detailed information about TIFF files:

// Configuration
// Processing Mode: Page Information

// Output includes:
{
  "tiff_info": {
    "total_pages": 15,
    "file_size": "2.5MB",
    "compression": "LZW",
    "color_mode": "RGB",
    "resolution": "300 DPI",
    "pages": [
      {
        "page_number": 1,
        "width": 2480,
        "height": 3508,
        "compression": "LZW"
      }
    ]
  }
}

Batch Page Extraction

Process multiple page ranges:

// Configuration
// Processing Mode: Extract Pages
// Page Range: ["1-3", "7-10", "15"]

// Output includes array of extracted page groups
{
  "extracted_groups": [
    {
      "range": "1-3",
      "pages": ["page_1.png", "page_2.png", "page_3.png"]
    },
    {
      "range": "7-10",
      "pages": ["page_7.png", "page_8.png", "page_9.png", "page_10.png"]
    },
    {
      "range": "15",
      "pages": ["page_15.png"]
    }
  ]
}

Format Conversion

Convert TIFF pages to different formats:

// Configuration
// Processing Mode: Convert Format
// Output Format: PNG

// Input message:
{
  "payload": {
    "tiff_path": "scans/document.tiff",
    "output_format": "PNG",
    "quality": 95
  }
}

// Output includes converted files
{
  "converted_files": [
    "document_page_1.png",
    "document_page_2.png",
    "document_page_3.png"
  ]
}

Output Structure

Split Results

{
  "operation": "split_tiff",
  "input_file": "documents/contract.tiff",
  "total_pages": 5,
  "output_directory": "split_pages/",
  "split_files": [
    "contract_page_1.png",
    "contract_page_2.png",
    "contract_page_3.png",
    "contract_page_4.png",
    "contract_page_5.png"
  ],
  "processing_time": 2.3,
  "status": "success"
}

Page Information

{
  "operation": "page_info",
  "input_file": "scans/report.tiff",
  "tiff_info": {
    "total_pages": 12,
    "file_size": "4.2MB",
    "compression": "LZW",
    "color_mode": "RGB",
    "resolution": "300 DPI",
    "creation_date": "2024-01-15T10:30:00Z"
  },
  "pages": [
    {
      "page_number": 1,
      "width": 2480,
      "height": 3508,
      "compression": "LZW",
      "file_size": "350KB"
    }
  ]
}

Tips

  • File Size Considerations: Large TIFF files may take longer to process
  • Memory Usage: Multi-page TIFF files require adequate memory for processing
  • Output Organization: Use descriptive output directories for better file management
  • Page Numbering: Page numbers start from 1, not 0
  • Format Support: Ensure output formats are compatible with downstream processing
  • Error Handling: Check for file existence and permissions before processing

Common Issues and Solutions

Large File Processing

  • Issue: Memory errors with very large TIFF files
  • Solution: Process pages in smaller batches or increase system memory

Permission Errors

  • Issue: Cannot write to output directory
  • Solution: Check directory permissions and ensure write access

Invalid Page Ranges

  • Issue: Page range exceeds available pages
  • Solution: Validate page ranges against total page count

Format Compatibility

  • Issue: Unsupported TIFF compression formats
  • Solution: Convert to standard compression before processing