Skip to content

File Conversion API

The file conversion API converts images, PDF, OFD, and TIFF inputs into image or document outputs. In the current CZUR implementation, single-image jpg / png / tiff single-page conversion uses czur-graphic-provider, while other page-set conversions use czur-file-convert-provider.

File Conversion Method

MethodParametersResponse dataNotes
file.convertsource?: object, target?: object, options?: object; also supports flat input_upload_id(s), input_path(s), output_path, output_dir, target_dir, output_format, export_type, exportType, pages, and base64task_id?, input_path(s), output_path, output_paths[], output_format, export_type, source_format, source_page_count, selected_page_count, accepted, converted, asset, assets[], outputs[], providerRuns file conversion synchronously and returns local asset metadata for converted outputs.

Parameter Shape

The structured shape is recommended. Flat parameters are still supported by the backend.

source

FieldTypeNotes
typestringSource type: image, images, base64, pdf, ofd, or tiff. Defaults to image when omitted.
formatstringSource format; usually optional and inferred from type or the input file extension.
input_upload_idstringOne upload ID, resolved to asset-original visible to the current connection.
input_upload_idsstring[]Multiple upload IDs. Image sources may use multiple inputs; PDF/OFD/TIFF document sources accept one input document per request.
input_pathstringOne local input path.
input_pathsstring[]Multiple local input paths.
base64stringBase64 image or image data URL. The backend writes it to a runtime temporary input file.
pagesstringDocument page selection, default all. Supports all or 1,3-5; page numbers are 1-based.

target

FieldTypeNotes
typestringTarget format: jpg, jpeg, png, tiff, pdf, or ofd. jpeg is normalized to jpg.
pathstringMulti-page output file path; also usable as the target file path when single-page output produces one file.
dirstringOutput directory for single-page/per-page export.

options

FieldTypeNotes
export_typestringsingle-page or multi-page, also accepts single_page / multi_page. jpg / png default to single-page; other targets default to multi-page.
qualitynumberOutput quality, default 90. The current implementation maps it to high/medium/low quality: >=70 high, >=40 medium, otherwise low.
render_dpinumberDPI used when rendering PDF/OFD pages to images, default 144.
pagesstringPage selection; takes precedence over source.pages.
tiff_colorstringTIFF color mode, default color. gray, grey, and grayscale output grayscale; other values output color.
tiff_compressionstringTIFF compression, default lzw. Supports lzw, none, jpeg / jpg, and group4 / g4.

Conversion Rules

SourceTargetexport_typeBehavior
One or more imagespdf / ofd / tiffmulti-pageMerges images into one multi-page file.
One or more imagesjpg / png / tiff / pdf / ofdsingle-pageWrites one output file per image.
PDF/OFD/TIFF documentjpg / png / tiffsingle-pageRenders each selected page to one image or TIFF file.
PDF/OFD/TIFF documentpdf / ofd / tiffsingle-pageWrites one single-page document per selected page.
PDF/OFD/TIFF documentpdf / ofd / tiffmulti-pageMerges selected pages into one target document.

Additional rules:

ItemNotes
Image target limitjpg / png targets only support export_type=single-page.
Document source limitpdf, ofd, and tiff sources accept one input document per request.
Default output directoryWhen output_dir / target.dir is omitted, the backend uses the runtime task asset directory.
Default multi-page pathWhen multi-page output omits output_path / target.path, the backend generates converted.<ext>.
Single-page namingMultiple outputs are named from the source file name and page number. If only one output is produced and output_path is provided, that path is used.
Document conversion semanticsPDF/OFD/TIFF sources are rendered page-by-page to images before target generation. Cross-document conversion does not guarantee preservation of text, vector, or semantic structure.

Response Fields

FieldTypeNotes
task_idstringOptional. Returned by the graphic fast path for single-image conversion.
input_path / input_paths[]string / string[]Local input paths actually used for conversion.
output_pathstringMain output path. Multi-page output uses the target file; multi-single-page output usually uses the first output file.
output_paths[]string[]All output file paths.
output_formatstringNormalized target format.
export_typestringNormalized export mode.
source_formatstringActual source format: image, pdf, ofd, or tiff.
source_page_countnumberSource page count. Image sources count input images.
selected_page_countnumberNumber of pages selected for conversion.
acceptednumberNumber of pages accepted for conversion.
convertednumberNumber of outputs generated; multi-page merge usually returns 1.
assetobjectFirst output registered in the local asset service.
assets[]arrayAll output assets.
outputs[]arrayOutput list; each item contains path, format, and asset.
providerstringActual provider, either czur-graphic-provider or czur-file-convert-provider.

asset / assets[] includes fields such as asset_id, kind, path, content_type, size, url, and download_url, which can be used for local preview or download.

Request Examples

Convert one image to PNG:

json
{
  "request_id": "req-convert-001",
  "method": "file.convert",
  "params": {
    "input_upload_id": "img-1760000000-1",
    "output_format": "png"
  }
}

Merge multiple images into one PDF:

json
{
  "request_id": "req-convert-002",
  "method": "file.convert",
  "params": {
    "source": {
      "type": "images",
      "input_upload_ids": ["img-1760000000-1", "img-1760000000-2"]
    },
    "target": {
      "type": "pdf",
      "path": "/tmp/sdk-demo/converted.pdf"
    },
    "options": {
      "export_type": "multi-page",
      "quality": 90
    }
  }
}

Split selected PDF pages to PNG:

json
{
  "request_id": "req-convert-003",
  "method": "file.convert",
  "params": {
    "source": {
      "type": "pdf",
      "input_upload_id": "doc-1760000000-1",
      "pages": "1,3-5"
    },
    "target": {
      "type": "png",
      "dir": "/tmp/sdk-demo/pages"
    },
    "options": {
      "export_type": "single-page",
      "render_dpi": 144
    }
  }
}

Convert a Base64 image to JPG:

json
{
  "request_id": "req-convert-004",
  "method": "file.convert",
  "params": {
    "source": {
      "type": "base64",
      "base64": "data:image/png;base64,iVBORw0KGgo..."
    },
    "target": {
      "type": "jpg",
      "dir": "/tmp/sdk-demo/images"
    },
    "options": {
      "export_type": "single-page",
      "quality": 90
    }
  }
}

CZUR Open Platform Documentation