{"id":26242392,"url":"https://github.com/cjrh/sembra","last_synced_at":"2025-08-08T08:54:07.172Z","repository":{"id":277878509,"uuid":"932970242","full_name":"cjrh/sembra","owner":"cjrh","description":"Seam carving image resizing","archived":false,"fork":false,"pushed_at":"2025-02-16T19:05:34.000Z","size":21500,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-28T19:53:22.535Z","etag":null,"topics":["command-line-tool","image-processing","image-resizing","seam-carving"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjrh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-AGPL","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":"2025-02-14T21:32:13.000Z","updated_at":"2025-02-16T19:05:37.000Z","dependencies_parsed_at":"2025-02-16T19:31:16.728Z","dependency_job_id":null,"html_url":"https://github.com/cjrh/sembra","commit_stats":null,"previous_names":["cjrh/sembra"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cjrh/sembra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fsembra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fsembra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fsembra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fsembra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjrh","download_url":"https://codeload.github.com/cjrh/sembra/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fsembra/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269393636,"owners_count":24409755,"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-08-08T02:00:09.200Z","response_time":72,"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":["command-line-tool","image-processing","image-resizing","seam-carving"],"created_at":"2025-03-13T09:51:46.887Z","updated_at":"2025-08-08T08:54:07.125Z","avatar_url":"https://github.com/cjrh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sembra\n\nSeam carving: content-aware image resizing.\n\n## About\n\nSeam carving is a content-aware image resizing technique that resizes an image by\nremoving or adding pixels in the least noticeable areas. The technique was first\ndeveloped by [Shai Avidan and Ariel Shamir in 2007](https://dl.acm.org/doi/abs/10.1145/1275808.1276390). \nThe technique was later improved by [Michael Rubinstein, Ariel Shamir, and Shai Avidan in 2008](https://dl.acm.org/doi/abs/10.1145/1360612.1360615).\n\nThe rust code in this repository is a port of the [Python code](https://github.com/li-plus/seam-carving) by [Jiahao Li](https://liplus.me/).\nFun fact, the port was done by the o1 model from OpenAI. It was nearly correct, and only two small bugs required fixing.\n\n## CLI Usage\n\n```sh\n$ sembra --help\nCLI for our seam carving demo\n\nUsage: sembra [OPTIONS] --input \u003cINPUT\u003e --output \u003cOUTPUT\u003e\n\nOptions:\n      --input \u003cINPUT\u003e              Input image path\n      --output \u003cOUTPUT\u003e            Output image path\n      --width \u003cWIDTH\u003e              Target width\n      --height \u003cHEIGHT\u003e            Target height\n      --energy-mode \u003cENERGY_MODE\u003e  Energy mode: \"backward\" or \"forward\" [default: backward]\n      --order \u003cORDER\u003e              Order mode: \"width-first\" or \"height-first\" [default: width-first]\n      --keep-mask \u003cKEEP_MASK\u003e      Keep mask image path (optional)\n      --drop-mask \u003cDROP_MASK\u003e      Drop mask image path (optional)\n      --step-ratio \u003cSTEP_RATIO\u003e    Step ratio for expansions [default: 0.5]\n  -h, --help                       Print help\n  -V, --version                    Print version\n```\n\n## Examples\n\nGenerally speaking, you get the best results if you go smaller. It is quite impressive\nhow well this works. Here is an example of resizing a rectangular image down into a\nsquare. We'll use the famous painting \u003cem\u003eNymphs and Satyr (1873)\u003c/em\u003e by William-Adolphe Bouguereau:\n\n```bash\n$ sembra --input nes.jpg --output nes_big_square.jpg \\\n    --width 350 --height 350 --energy-mode forward\n```\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"nes.jpg\" alt=\"Original\"\u003e\n      \u003cp align=\"center\"\u003eOriginal 350x500\u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"nes_small_square.jpg\" alt=\"Resized smaller\"\u003e\n      \u003cp align=\"center\"\u003eReduced 350x350\u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nWe turned a rectangular image into a square with very little observable distortion!\nQuite remarkable.\n\nYou can also go bigger, but the results are not as good. Here is an example of the same\nimage, but this time we enlarge the width to make it square:\n\n```bash\n$ sembra --input nes.jpg --output nes_big_square.jpg \\\n    --width 500 --height 500 --energy-mode forward\n```\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"nes.jpg\" alt=\"Original\"\u003e\n      \u003cp align=\"center\"\u003eOriginal 350x500\u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"nes_big_square.jpg\" alt=\"Resized larger\"\u003e\n      \u003cp align=\"center\"\u003eEnlarged 500x500\u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nWhile there is clearly some distortion, there is also excellent preservation\nof some of the more detailed parts of the image. This is what seam carving\ngives you. You can see this by comparing the seam-carving enlargement versus what\nyou get from a typical image resize (resampling) in an image editor:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"nes_big_square.jpg\" alt=\"Original\"\u003e\n      \u003cp align=\"center\"\u003eSeam-carved up 500x500\u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"nes-gimp-500.jpg\" alt=\"Resized larger\"\u003e\n      \u003cp align=\"center\"\u003eResampling 500x500\u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nSide-by-side, you can clearly see (may need to zoom the page) that the seam-carving enlargment has preserved\ndetail in key areas, like faces, fingers, eyes, and so on. Of course, this comes\nat the cost greater distortion in other less detailed areas.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjrh%2Fsembra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjrh%2Fsembra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjrh%2Fsembra/lists"}