Skip to content

Image API

Image APIs include synchronous image processing, asynchronous image enhancement pipelines, and enhancement workflow management.

Common Input

FieldTypeRequiredNotes
input_upload_idstringConditionalID returned by local HTTP upload. Synchronous processing methods use one upload ID.
input_pathstringConditionalLocal file path. Synchronous processing methods use one local path.
input_upload_idsstring[]ConditionalUsed for multi-image enhancement under source in image.enhance.
input_pathsstring[]ConditionalUsed for multi-image enhancement under source in image.enhance.
output_pathstringNoOutput file path. Used by synchronous processing methods.
output_dirstringNoOutput directory; runtime task asset directory is used when empty.

Synchronous processing methods require at least one of input_upload_id and input_path. input_upload_id is resolved to a registered asset visible to the current connection and then processed as a local input file.

The values for page_processing, color_mode, single_page, curved_book, and selected_area match the capture module. See Capture API / CZUR Provider Capabilities.

Synchronous Processing Methods

MethodParametersResponse dataNotes
image.processCommon input, page_processing?: string=keep_original, color_mode?: string=no_optimize, output_format?: string=jpg, single_page?: object, curved_book?: object, selected_area?: object, scan_device_type?: number, profile?: CaptureProfiletask_id, input_upload_id, input_path, output_path, outputs[], assets[], page_processing, color_mode, output_format, processed, providerPage processing + color mode + format output.
image.process_pageCommon input, page_processing?: string=single_page, single_page?: object, curved_book?: object, selected_area?: object, scan_device_type?: number, profile?: CaptureProfiletask_id, input_upload_id, input_path, output_path, outputs[], assets[], page_processing, output_format, processed, providerPage processing only. Output format must match input format.
image.apply_color_modeCommon input, color_mode?: string=no_optimize, profile?: CaptureProfiletask_id, input_upload_id, input_path, output_path, outputs[], assets[], color_mode, output_format, processed, providerColor mode only. Output format must match input format.

Synchronous processing is executed by czur-graphic-provider:

BehaviorNotes
image.processRuns page processing, color processing, then format conversion. output_format uses the explicit parameter first, then the output_path extension, then defaults to jpg.
image.process_pageDefaults to page_processing=single_page. If the output_path extension differs from the input format, an invalid-params error is returned.
image.apply_color_modeUses profile.capture.color_mode when color_mode is omitted; if still empty, defaults to no_optimize. If the output_path extension differs from the input format, an invalid-params error is returned.
profile overrideWhen profile is provided, page-processing, color-mode, and output-format fields are read from it first; top-level explicit parameters take precedence.
selected_areaWhen provided, the page-processing mode is switched to selected_area.

outputs[] / assets[]

outputs[] describes the processing outputs. assets[] contains the same outputs registered in the local asset service. Both can be used to read results; UI previews usually use outputs[].url or outputs[].download_url.

FieldTypeNotes
asset_idstringAsset ID, such as asset-final, asset-page, or asset-color.
output_idstringProvider output ID, useful for multi-page output.
rolestringOutput role, such as page, color, or final.
indexnumberOutput index, starting at 0.
pathstringLocal output file path.
urlstringLocal HTTP asset URL.
download_urlstringLocal HTTP asset download URL.
content_typestringMIME type.
width / heightnumberOutput image dimensions.
sizenumberOutput file size in bytes.

ImageEnhancePipeline

FieldTypeNotes
versionstringDefault image.enhance.pipeline.v1.
steps[]arrayEnhancement steps executed in order. Steps without type are ignored.
steps[].idstringStep ID; generated as step-N by runtime when empty.
steps[].typestringCapability type, such as blank_page_detect, normalize_spec, or doc_crop_enhance.
steps[].providerstringDefault auto. The current implementation runs the registered image enhancement provider.
steps[].enabledbooleanDefault true; false skips the step.
steps[].on_errorstringfail or skip, default fail.
steps[].paramsobjectCapability parameters. Prefer generating them from defaults and schema returned by image.enhance_capabilities.
target.typestringOutput target type, default images. Supports images, pdf, ofd, tiff, jpg, and png.
target.formatstringImage output format, default jpg; document targets use target.type as the output format.
target.export_typestringsingle-page or multi-page. Image targets default to single-page; document targets default to multi-page.
target.path / target.output_pathstringFinal output file path.
target.dir / target.output_dirstringFinal output directory.
target.qualitynumberOutput quality, default 90.
target.tiff_colorstringTIFF output color mode, default color.
target.tiff_compressionstringTIFF compression, default lzw.
options.keep_intermediatebooleanWhether to keep intermediate outputs, default false.
options.include_metadatabooleanWhether to include metadata, default true.

Image Enhancement Methods

MethodParametersResponse dataNotes
image.enhance_capabilitiesnoneproviders[], pipeline_versionReturns provider, capabilities, defaults, schema, localized text, and online availability.
image.enhancesource.input_upload_id(s) or source.input_path(s), pipeline: ImageEnhancePipeline, output_dir?: stringaccepted, task_id, status, taskSubmits an async enhancement task. Input fields are also accepted directly at top-level params.
image.enhance_gettask_id: string requiredtask_id, taskGets task snapshot. Only the connection that created the task may query it.
image.enhance_canceltask_id: string requiredaccepted, task_id, taskCancels task. Only the connection that created the task may cancel it.
image.enhance_workflow_listnoneworkflows[], count, providerLists saved workflows.
image.enhance_workflow_getworkflow_id: string requiredworkflowGets one workflow.
image.enhance_workflow_saveworkflow object, or direct name, description, pipelinesaved, updated, workflowSaves or updates a workflow; workflow_id is generated when missing.
image.enhance_workflow_deleteworkflow_id: string requireddeleted, workflow_id, countDeletes a workflow.

Enhance capabilities Response Shape

image.enhance_capabilities uses the common Command WS response envelope. Enhancement capabilities are returned under data. The current private implementation provider is private-image-enhance-provider, with kind set to mixed:

json
{
  "request_id": "req-enhance-cap-001",
  "id": "req-enhance-cap-001",
  "code": 0,
  "message": "ok",
  "data": {
    "pipeline_version": "image.enhance.pipeline.v1",
    "providers": [
      {
        "provider": "private-image-enhance-provider",
        "kind": "mixed",
        "available": true,
        "capabilities": [
          {
            "type": "blank_page_detect",
            "title": "Blank page detection",
            "description": "Detects blank pages and can mark or remove them from the output sequence.",
            "i18n_key": "image_enhance.blank_page_detect",
            "localized": {
              "en": {
                "title": "Blank page detection",
                "description": "Detects blank pages and can mark or remove them from the output sequence."
              },
              "zh-CN": {
                "title": "空白页检测",
                "description": "检测空白页,可选择标记空白页或从输出序列中移除。"
              }
            },
            "category": "detect",
            "runtime": "offline",
            "available": true,
            "unavailable_reason": "",
            "requires_capability": "image.enhance",
            "quota_unit": "page",
            "input": {
              "source_types": ["image", "images"],
              "min_pages": 1,
              "max_pages": 1000
            },
            "output": {
              "page_effect": "filter",
              "metadata": true
            },
            "defaults": {
              "action": "drop",
              "threshold": 0.98
            },
            "schema": {},
            "order_hint": 40,
            "version": "1.0"
          }
        ]
      }
    ]
  },
  "ts": 1710000000
}

data fields:

FieldTypeNotes
pipeline_versionstringPipeline version to use as ImageEnhancePipeline.version.
providers[]arrayAvailable image enhancement providers.
providers[].providerstringProvider name, useful for identifying the capability source.
providers[].kindstringProvider kind, such as offline, online, or mixed.
providers[].availablebooleanWhether the provider is currently available.
providers[].capabilities[]arrayEnhancement capabilities supported by the provider.

Current private-image-enhance-provider capabilities provided by CZUR:

TypeRuntimeCategoryNotes
crop_enhanceofflinecleanupCrops pages by top, bottom, left, and right percentages, or keeps the canvas and fills the outside area with white.
normalize_specofflinenormalizeStandardizes page size, DPI, background, alignment, and fill rules.
rotateofflinenormalizeRotates manually, or automatically rotates and deskews by text direction.
blank_page_detectofflinedetectDetects blank pages and can mark or remove them from the output sequence.
red_green_headofflineenhanceEnhances red or green header documents with an offline algorithm.
doc_crop_enhanceonlineenhanceOnline document perspective correction, cleanup, and visual enhancement.
remove_handwritingonlineenhanceOnline removal of handwriting traces.
doc_repaironlineenhanceOnline reduction of paper texture, watermark-like background, and patterned noise.
remove_moireonlineenhanceOnline moire removal.

Online capabilities require an online enhancement API key. When it is not configured, they return available=false with unavailable_reason and localized.*.unavailable_reason.

capabilities[] fields:

FieldTypeNotes
typestringCapability type; use it as pipeline.steps[].type when composing a pipeline.
title / descriptionstringDefault English title and description.
i18n_keystringLocalization key for frontend or caller-side UI.
localized.en / localized.zh-CNobjectEnglish and Chinese copy; may include unavailable_reason when unavailable.
categorystringCapability category, such as cleanup, normalize, detect, or enhance.
runtimestringExecution location, such as offline or online.
availablebooleanWhether the capability is currently available; online capabilities are usually false when not configured.
unavailable_reasonstringReason why the capability is unavailable; can be shown to users or used for diagnostics.
requires_capabilitystringAuthorization capability required for this step, such as image.enhance or image.enhance.online.
quota_unitstringBilling or quota unit; currently usually page.
input.source_types[]string[]Supported input types, such as image and images.
input.min_pages / input.max_pagesnumberSupported input page range.
output.page_effectstringPage effect, such as transform or filter.
output.metadatabooleanWhether the capability mainly outputs metadata.
defaultsobjectRecommended default parameters; use as the starting point for pipeline.steps[].params.
schemaobjectParameter schema for UI generation or validation.
order_hintnumberUI ordering hint.
versionstringCapability definition version.

Enhancement Task Snapshot

task contains task state, step state, page results, and final assets:

FieldTypeNotes
task_idstringTask ID.
statusstringqueued, running, completed, failed, or cancelled.
phasestringCurrent phase, such as queued, enhancing, converting, completed, failed, or cancelled.
progressnumberProgress, from 0 to 100.
input_page_count / output_page_countnumberInput page count and current output page count.
pages[]arrayCurrent page list.
steps[]arrayExecuted step snapshots.
assets[]arrayRegistered output assets after completion.
warnings[]string[]Non-fatal warnings.
output_path / output_paths[]string / string[]Final output paths.
output_type / output_format / export_typestringOutput target information.
errorstringFailure reason.
cancel_requestedbooleanWhether cancellation was requested.

pages[] fields: source_index, output_index, path, dropped, and metadata.

steps[] fields: id, type, status, provider, input_page_count, output_page_count, metadata, warnings[], and message.

Events

When an asynchronous enhancement task changes state, Command WS pushes image.enhance_changed:

json
{
  "event": "image.enhance_changed",
  "code": 0,
  "message": "ok",
  "payload": {
    "task_id": "image-enhance-1",
    "task": {
      "task_id": "image-enhance-1",
      "status": "running",
      "phase": "enhancing",
      "progress": 5
    }
  },
  "ts": 1710000000
}

CZUR Open Platform Documentation