{"id":21660331,"url":"https://github.com/slub/textract2page","last_synced_at":"2025-07-28T18:06:55.796Z","repository":{"id":157388639,"uuid":"633451468","full_name":"slub/textract2page","owner":"slub","description":"Convert AWS Textract JSON to PRImA PAGE XML","archived":false,"fork":false,"pushed_at":"2025-02-03T11:53:05.000Z","size":80591,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-14T01:35:02.239Z","etag":null,"topics":["ocr","page-xml","python","textract"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-27T14:23:15.000Z","updated_at":"2025-02-03T11:53:08.000Z","dependencies_parsed_at":"2025-02-03T08:32:10.607Z","dependency_job_id":null,"html_url":"https://github.com/slub/textract2page","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/slub/textract2page","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slub%2Ftextract2page","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slub%2Ftextract2page/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slub%2Ftextract2page/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slub%2Ftextract2page/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slub","download_url":"https://codeload.github.com/slub/textract2page/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slub%2Ftextract2page/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267560512,"owners_count":24107500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ocr","page-xml","python","textract"],"created_at":"2024-11-25T09:33:04.333Z","updated_at":"2025-07-28T18:06:55.765Z","avatar_url":"https://github.com/slub.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# textract2page\n\n\u003e Convert AWS Textract JSON to PRImA PAGE XML\n\n[![PyPI Release](https://img.shields.io/pypi/v/textract2page.svg)](https://pypi.org/project/textract2page/)\n[![CI Tests](https://github.com/rue-a/textract2page/actions/workflows/test.yml/badge.svg)](https://github.com/rue-a/textract2page/actions/workflows/test.yml)\n\n## Introduction\n\nThis software converts OCR results from\n[Amazon AWS Textract Response](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-document-layout.html)\nfiles to [PRImA PAGE XML](https://github.com/PRImA-Research-Lab/PAGE-XML) files.\n\n## Installation\n\nIn a Python [virtualenv](https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments):\n\n    pip install textract2page\n\n## Usage\n\nThe package contains a **file-based** conversion function provided as CLI and Python API.\n(So this does not directly use the AWS API, which might be supported in the future.)\n\nThe function takes the Textract JSON file and the original image file which was used\nas input for the OCR. (That is necessary because Textract stores coordinates in\n`float` ratios, whereas PAGE uses `int` in pixel indices. However, if the with and height\nof the image are passed as well, then the file is not needed – see below.)\n\n\u003e **Note**: Only supports single-page requests. Multi-page JSON results must first be\n\u003e split up, for example via\n\u003e ```sh\n\u003e     jq '{Blocks: [.Blocks[] | select(.Page == 1)]}' aws.json \u003e aws-page1.json\n\u003e     jq '{Blocks: [.Blocks[] | select(.Page == 2)]}' aws.json \u003e aws-page2.json\n\u003e     jq '{Blocks: [.Blocks[] | select(.Page == 3)]}' aws.json \u003e aws-page3.json\n\u003e ```\n\n### Python API\n\nTo convert a Textract file `example.json` for an image file `example.jpg` to a PAGE `example.xml`:\n\n```python\nfrom textract2page import convert_file\n\nconvert_file(\"example.json\", \"example.jpg\", \"example.xml\")\n```\n\nAlternatively, if you do not have access to the image file, \nbut do know its pixel resolution, use:\n\n```python\nfrom textract2page import convert_file_without_image\n\nconvert_file_without_image(\"example.json\",\n    # just give it a name (will not be read):\n    \"example.jpg\",\n    # set image width so PAGE coordinates will be correct:\n    2135,\n    # set image height so PAGE coordinates will be correct:\n    3240,\n    \"example.xml\")\n```\n\n\n### CLI\n\nAnalogously, on the command line interface:\n\n    # with image file (path must be readable)\n    textract2page example.json example.jpg \u003e example.xml\n    textract2page -O example.xml example.json example.jpg\n    # without image file (just keep path name)\n    textract2page --image-width 2135 --image-height 3240 example.json example.jpg \u003e example.xml\n    textract2page --image-width 2135 --image-height 3240 -O example.xml example.json example.jpg\n\nYou can get a list of options with `--help` or `-h`\n\n## Testing\n\nRequires installation and a local copy of the repository.\n\nTo run regression tests with `pytest`, do\n\n    make deps-test\n    make test-api\n\nTo run regression test via command line, do\n\n    # optionally:\n    sudo apt-get install xmlstarlet\n    make test-cli\n\n(If `xmlstarlet` is available, then the CLI test will\nalso validate the result tree. Otherwise, this just\nchecks the command completes without error.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslub%2Ftextract2page","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslub%2Ftextract2page","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslub%2Ftextract2page/lists"}