{"id":15932880,"url":"https://github.com/krithin/trimpictures","last_synced_at":"2026-05-16T22:06:58.062Z","repository":{"id":68786616,"uuid":"343330210","full_name":"krithin/trimpictures","owner":"krithin","description":"Tool to trim and deskew scanned images.","archived":false,"fork":false,"pushed_at":"2021-03-29T15:14:32.000Z","size":6273,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T03:28:21.495Z","etag":null,"topics":["deskew","opencv","opencv-python","scanning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krithin.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":"2021-03-01T07:42:08.000Z","updated_at":"2024-07-30T03:46:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"daba0e66-d1da-46f5-b98d-83575de146da","html_url":"https://github.com/krithin/trimpictures","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"32c2f5246bec99e31f06692d40048565726aaec2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krithin%2Ftrimpictures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krithin%2Ftrimpictures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krithin%2Ftrimpictures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krithin%2Ftrimpictures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krithin","download_url":"https://codeload.github.com/krithin/trimpictures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247023166,"owners_count":20870928,"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","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":["deskew","opencv","opencv-python","scanning"],"created_at":"2024-10-07T02:04:11.396Z","updated_at":"2026-05-16T22:06:53.040Z","avatar_url":"https://github.com/krithin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trim Pictures\n\nThis Python script automatically trims and deskews scanned photos.\n\nWhen scanning images on a flatbed scanner I've tended to run into a few problems: it's hard to place a photo on the scanner bed such that it ends up being perfectly axis-aligned without chopping off part of the image; and it's hard to accurately trim the boundaries of the scan region to precisely match the edges of the photograph being scanned.\n\nThis is a small command-line tool that helps solve those problems while being robust to background smudges from dirt and dust on the scanner bed. The script works just fine whether the background to be deleted is dark or light. As a bonus, it can also convert images between common file formats.\n\n## Samples\nInput                                                              |  Output\n:-----------------------------------------------------------------:|:-------------------------:\n![Input image with skew and dark border](samples/sampleinput.png)  |  ![Output image aligned and border removed](samples/sampleoutput.jpg)\n![Input image with light border and jagged edge](samples/lightinput.png)  |  ![Output image border removed](samples/lightoutput.jpg)\n\nThe trimming effect in the second image is easier to see if you highlight it or view it on a dark background. Of course this works just fine with more modern, colour photo prints as well.\n\nBy the way - if you know where the first photo was taken or what's going on in it, or any of the people in the second photo, please contact me!\n\n## Installation\nAs with most other Python software, first clone the repository, then create and activate a virtualenv:\n\n```\n$ python -m venv venv\n$ source venv/bin/activate\n```\n\nThen just install the dependencies listed in requirements.txt:\n\n```\n$ pip install -r requirements.txt\n```\n\n## Usage\nWith the virtualenv active,\n```\n$ python trim.py input.jpg output.jpg\n```\nIt'll bring up a series of windows displaying the image and the contours extracted from it as it goes along; press any key to step through the sequence to the next image. To skip the intermediate visualizations and just write the output image file, add the `--quiet` flag.\n\nTo process a whole folder of images at once just use your shell's loop statment - e.g. in [fish](http://fishshell.com/) (which I highly recommend) I can process a batch of `png` images from an `Originals` folder and write the output files to `jpg` like so:\n```\n\u003e for i in Originals/*.png\n      python trim.py --quiet $i (basename $i .png).jpg\n  end\n```\nAn analogous construct exists for `bash` as well, of course.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrithin%2Ftrimpictures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrithin%2Ftrimpictures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrithin%2Ftrimpictures/lists"}