Method 1: Request a ZIP during parsing
This method requires the fewest steps. Use it when you have not parsed the document yet or can parse it again.output_formats is an array. It can contain only zip (the ZIP contains the Markdown and images), or it can request both json and zip. After parsing, the API returns the ZIP download URL in data.result.outputs.zip.
1
Prepare the request
Prepare the source document and a SoMark API key. Do not store a real API key in your code repository.
2
Request ZIP and image file output
Include
zip in output_formats. When output_formats includes zip, element_formats.image can only be set to file. The example below requests both zip and json outputs:Python
3
Submit the document and wait
Call the sync parsing endpoint and inspect
code in the response. A value of 0 means the request succeeded.4
Download and inspect the ZIP
Read the URL from 
Markdown and image files after extraction:
data.result.outputs.zip, download and extract the archive, then confirm that it contains Markdown and image files.ZIP URL in the response:

output_formats parameter reference
Method 2: Use the image persistence Skill
Use thesomark-localize-images Skill when you already have a .md or .markdown file whose Markdown images or HTML <img> elements still use HTTP(S) URLs. The current implementation is version 1.4.0. It requires Python 3.8 or later and Pillow>=9.4.0,<11.0.0.
1
Install the dependency
Install the dependency from the Skill directory you received:
2
Trigger the Skill with natural language
In a Skill-capable agent, enter a prompt such as:
3
Process one file
You can also run the bundled script directly:If you omit
-o, the script creates a directory beside the input using the source filename. For example, result.md defaults to result/.4
Process a directory
Pass a directory to recursively process all Batch mode continues after an individual document fails. It returns a nonzero exit code and lists the failed files. Do not put the batch output directory inside the input directory.
.md and .markdown files. Each document receives an isolated package:

0, target images in main.md use ./images/image_NNN.jpg, and every referenced image exists and is nonempty. Finally, open main.md in a local Markdown viewer and confirm that the images render.

The Skill detects image formats from their content, decodes each image, and re-encodes every output as JPEG. Transparent areas use a white background. A repeated URL is downloaded once. The Skill writes the new
main.md only after every image succeeds, and it never modifies the source Markdown.Download and file protection options
- Each HTTP request has a 60-second timeout and 3 retries by default. For a slow network, use
--workers 2 --timeout 120 --retries 5. - Each image has a default 100 MB size limit. Use
--max-image-mbto change it. - Use the repeatable
--allowed-host <domain>option to restrict downloads. Redirect destinations are checked too. - The Skill refuses to overwrite existing Markdown or images with different content. Use
--forceonly when replacement is intentional. - The Skill creates a directory package and does not create a ZIP automatically. Compress the verified output separately when needed.
Method 3: Reuse Python code directly
The following is a simplified example for the common single-Markdown-file workflow. It supports HTTP(S) images in Markdown and HTML<img> elements, converts downloaded images to JPEG, writes main.md and images/image_NNN.jpg, and leaves the source Markdown unchanged.
Compared with the full Skill, this example omits directory batch processing, domain allowlists, concurrent downloads, maximum image size limits, fenced-code protection, and --force replacement. It refuses to use an existing output directory so that it cannot silently overwrite files.
Install the dependency:
localize_somark_images.py:
View the complete Python script
View the complete Python script
How to choose
- You have not parsed the document yet: request a ZIP during parsing.
- You already have Markdown and use an agent tool: use the image persistence Skill.
- You need to integrate or modify the logic: reuse the Python code.

