[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5040":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":15,"stars30d":15,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":36,"lastSyncTime":37,"discoverSource":38},5040,"caire","esimov\u002Fcaire","esimov","Content aware image resize library","",null,"Go",10468,386,159,1,0,42.76,"MIT License",false,"master",true,[23,24,25,26,27,28,29,30,31,32],"computer-vision","content-aware-resize","content-aware-scaling","edge-detection","face-detection","golang","image-processing","image-resize","machine-learning","seam-carving","2026-06-12 02:01:07","\u003Ch1 align=\"center\">\u003Cimg alt=\"Caire Logo\" src=\"https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F51555990-a1762600-1e81-11e9-9a6a-0cd815870358.png\" height=\"180\">\u003C\u002Fh1>\n\n[![build](https:\u002F\u002Fgithub.com\u002Fesimov\u002Fcaire\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fesimov\u002Fcaire\u002Factions\u002Fworkflows\u002Fbuild.yml)\n[![Go Reference](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fgithub.com\u002Fesimov\u002Fcaire.svg)](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fesimov\u002Fcaire)\n[![license](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fesimov\u002Fcaire)](.\u002FLICENSE)\n[![release](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Frelease-v1.5.0-blue.svg)](https:\u002F\u002Fgithub.com\u002Fesimov\u002Fcaire\u002Freleases\u002Ftag\u002Fv1.5.0)\n[![homebrew](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fhomebrew-v1.5.0-orange.svg)](https:\u002F\u002Fformulae.brew.sh\u002Fformula\u002Fcaire)\n[![caire](https:\u002F\u002Fsnapcraft.io\u002Fcaire\u002Fbadge.svg)](https:\u002F\u002Fsnapcraft.io\u002Fcaire)\n\n**Caire** is a content aware image resize library based on *[Seam Carving for Content-Aware Image Resizing](https:\u002F\u002Finst.eecs.berkeley.edu\u002F~cs194-26\u002Ffa16\u002Fhw\u002Fproj4-seamcarving\u002Fimret.pdf)* paper.\n\n## How does it work\n* An energy map (edge detection) is generated from the provided image.\n* The algorithm tries to find the least important parts of the image taking into account the lowest energy values.\n* Using a dynamic programming approach the algorithm will generate individual seams across the image from top to down, or from left to right (depending on the horizontal or vertical resizing) and will allocate for each seam a custom value, the least important pixels having the lowest energy cost and the most important ones having the highest cost.\n* We traverse the image from the second row to the last row and compute the cumulative minimum energy for all possible connected seams for each entry.\n* The minimum energy level is calculated by summing up the current pixel value with the lowest value of the neighboring pixels obtained from the previous row.\n* We traverse the image from top to bottom and compute the minimum energy level. For each pixel in a row we compute the energy of the current pixel plus the energy of one of the three possible pixels above it.\n* Find the lowest cost seam from the energy matrix starting from the last row and remove it.\n* Repeat the process.\n\n#### The process illustrated:\n\n| Original image | Energy map | Seams applied\n|:--:|:--:|:--:|\n| ![original](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35481925-de130752-0435-11e8-9246-3950679b4fd6.jpg) | ![sobel](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35481899-5d5096ca-0435-11e8-9f9b-a84fefc06470.jpg) | ![debug](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35481949-5c74dcb0-0436-11e8-97db-a6169cb150ca.jpg) | ![out](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35564985-88c579d4-05c4-11e8-9068-5141714e6f43.jpg) |\n\n## Features\nKey features which differentiates this library from the other existing open source solutions:\n\n- [x] **GUI progress indicator**\n- [x] Customizable command line support\n- [x] Support for both shrinking or enlarging the image\n- [x] Resize image both vertically and horizontally\n- [x] Face detection to avoid face deformation\n- [x] Support for multiple output image type (jpg, jpeg, png, bmp)\n- [x] Support for `stdin` and `stdout` pipe commands\n- [x] Can process whole directories recursively and concurrently\n- [x] Use of sobel threshold for fine tuning\n- [x] Use of blur filter for increased edge detection\n- [x] Support for squaring the image with a single command\n- [x] Support for proportional scaling\n- [x] Support for protective mask\n- [x] Support for removal mask\n- [x] [GUI debug mode support](#masks-support)\n\n## Install\nFirst, install Go, set your `GOPATH`, and make sure `$GOPATH\u002Fbin` is on your `PATH`.\n\n```bash\n$ go install github.com\u002Fesimov\u002Fcaire\u002Fcmd\u002Fcaire@latest\n```\n\n## MacOS (Brew) install\nThe library can also be installed via Homebrew.\n\n```bash\n$ brew install caire\n```\n\n## Usage\n\n```bash\n$ caire -in input.jpg -out output.jpg\n```\n\n### Supported commands:\n```bash\n$ caire --help\n```\nThe following flags are supported:\n\n| Flag | Default | Description |\n| --- | --- | --- |\n| `in` | - | Input file |\n| `out` | - | Output file |\n| `width` | n\u002Fa | New width |\n| `height` | n\u002Fa | New height |\n| `preview` | true | Show GUI window |\n| `perc` | false | Reduce image by percentage |\n| `square` | false | Reduce image to square dimensions |\n| `blur` | 4 | Blur radius |\n| `sobel` | 2 | Sobel filter threshold |\n| `debug` | false | Use debugger |\n| `face` | false | Use face detection |\n| `angle` | float | Plane rotated faces angle |\n| `mask` | string | Mask file path |\n| `rmask` | string | Remove mask file path |\n| `color` | string | Seam color (default `#ff0000`) |\n| `shape` | string | Shape type used for debugging: `circle`,`line` (default `circle`) |\n\n## Face detection\n\nThe library is capable of detecting human faces prior resizing the images by using the lightweight Pigo (https:\u002F\u002Fgithub.com\u002Fesimov\u002Fpigo) face detection library.\n\nThe image below illustrates the application capabilities for human face detection prior resizing. It's clearly visible that with face detection activated the algorithm will avoid cropping pixels inside the detected faces, retaining the face zone unaltered.\n\n| Original image | With face detection | Without face detection\n|:--:|:--:|:--:|\n| ![Original](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F37569642-0c5f49e8-2aee-11e8-8ac1-d096c0387ca0.jpg) | ![With Face Detection](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F41292871-6ca43280-6e5c-11e8-9d72-5b9a138228b6.jpg) | ![Without Face Detection](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F41292872-6cc90e8e-6e5c-11e8-8b41-5b4eb5042381.jpg) |\n\n[Sample image source](http:\u002F\u002Fwww.lens-rumors.com\u002Fwp-content\u002Fuploads\u002F2014\u002F12\u002FEF-M-55-200mm-f4.5-6.3-IS-STM-sample.jpg)\n\n### GUI progress indicator\n\n\u003Cp align=\"center\">\u003Cimg alt=\"GUI preview\" title=\"GUI preview\" src=\"https:\u002F\u002Fgithub.com\u002Fesimov\u002Fcaire\u002Fraw\u002Fmaster\u002Fgui_preview.gif\">\u003C\u002Fp>\n\nA GUI preview mode is also incorporated into the library for in time process visualization. The [Gio](http:\u002F\u002Fgioui.org\u002F) GUI library has been used because of its robustness and modern architecture. Prior running it please make sure that you have installed all the required dependencies noted in the installation section (https:\u002F\u002Fgioui.org\u002F#installation) .\n\nThe preview window is activated by default but you can deactivate it any time by setting the `-preview` flag to false. When the images are processed concurrently from a directory the preview mode is deactivated.\n\n### Face detection to avoid face deformation\nIn order to detect faces prior rescaling, use the `-face` flag. There is no need to provide a face classification file, since it's already embedded into the generated binary file. The sample code below will resize the provided image with 20%, but checks for human faces in order tot avoid face deformations.\n\nFor face detection related settings please check the Pigo [documentation](https:\u002F\u002Fgithub.com\u002Fesimov\u002Fpigo\u002Fblob\u002Fmaster\u002FREADME.md).\n\n```bash\n$ caire -in input.jpg -out output.jpg -face=1 -perc=1 -width=20\n```\n\n### Support for `stdin` and `stdout` pipe commands\nYou can also use `stdin` and `stdout` with `-`:\n\n```bash\n$ cat input\u002Fsource.jpg | caire -in - -out - >out.jpg\n```\n\n`in` and `out` default to `-` so you can also use:\n\n```bash\n$ cat input\u002Fsource.jpg | caire >out.jpg\n$ caire -out out.jpg \u003C input\u002Fsource.jpg\n```\n\nYou can provide also an image URL for the `-in` flag or even use **curl** or **wget** as a pipe command in which case there is no need to use the `-in` flag.\n\n```bash\n$ caire -in \u003Cimage_url> -out \u003Coutput-folder>\n$ curl -s \u003Cimage_url> | caire > out.jpg\n```\n\n### Process multiple images from a directory concurrently\nThe library can also process multiple images from a directory **concurrently**. You have to provide only the source and the destination folder and the new width or height in this case.\n\n```bash\n$ caire -in \u003Cinput_folder> -out \u003Coutput-folder>\n```\n\n### Support for multiple output image type\nThere is no need to define the output file type, just use the correct extension and the library will encode the image to that specific type.\n\n### Other options\nIn case you wish to scale down the image by a specific percentage, it can be used the **`-perc`** boolean flag. In this case the values provided for the `width` and `height` are expressed in percentage and not pixel values. For example to reduce the image dimension by 20% both horizontally and vertically you can use the following command:\n\n```bash\n$ caire -in input\u002Fsource.jpg -out .\u002Fout.jpg -perc=1 -width=20 -height=20 -debug=false\n```\n\nAlso the library supports the **`-square`** option. When this option is used the image will be resized to a square, based on the shortest edge.\n\nWhen an image is resized on both the X and Y axis, the algorithm will first try to rescale it prior resizing, but also will preserve the image aspect ratio. The seam carving algorithm is applied only to the remaining points. Ex. : given an image of dimensions 2048x1536 if we want to resize to the 1024x500, the tool first rescale the image to 1024x768 and then will remove only the remaining 268px.\n\n### Masks support:\n\n- `-mask`: The path to the protective mask. The mask should be in binary format and have the same size as the input image. White areas represent regions where no seams should be carved.\n- `-rmask`: The path to the removal mask. The mask should be in binary format and have the same size as the input image. White areas represent regions to be removed.\n\nMask | Mask removal\n:-: | :-:\n\u003Cvideo src='https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F197509861-86733da8-0846-419a-95eb-4fb5a97607d5.mp4' width=180\u002F> | \u003Cvideo src='https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F197397857-7b785d7c-2f80-4aed-a5d2-75c429389060.mp4' width=180\u002F>\n\n### Caire integrations\n- [x] Caire can be used as a serverless function via OpenFaaS: https:\u002F\u002Fgithub.com\u002Fesimov\u002Fcaire-openfaas\n- [x] Caire can also be used as a `snap` function (https:\u002F\u002Fsnapcraft.io\u002Fcaire): `$ snap run caire --h`\n\n\u003Ca href=\"https:\u002F\u002Fsnapcraft.io\u002Fcaire\">\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fsnapcore\u002Fsnap-store-badges\u002Fmaster\u002FEN\u002F%5BEN%5D-snap-store-white-uneditable.png\" alt=\"snapcraft caire\">\u003C\u002Fa>\n\n## Results\n\n#### Shrunk images\n| Original | Shrunk |\n| --- | --- |\n| ![broadway_tower_edit](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498083-83d6015e-04d5-11e8-936a-883e17b76f9d.jpg) | ![broadway_tower_edit](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498110-a4a03328-04d5-11e8-9bf1-f526ef033d6a.jpg) |\n| ![waterfall](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498250-2f31e202-04d6-11e8-8840-a78f40fc1a0c.png) | ![waterfall](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498209-0411b16a-04d6-11e8-9ce2-ec4bce34828a.jpg) |\n| ![dubai](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498466-1375b88a-04d7-11e8-8f8e-9d202da6a6b3.jpg) | ![dubai](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498499-3c32fc38-04d7-11e8-9f0d-07f63a8bd420.jpg) |\n| ![boat](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498465-1317a678-04d7-11e8-9185-ec92ea57f7c6.jpg) | ![boat](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498498-3c0f182c-04d7-11e8-9af8-695bc071e0f1.jpg) |\n\n#### Enlarged images\n| Original | Extended |\n| --- | --- |\n| ![gasadalur](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498662-e11853c4-04d7-11e8-98d7-fcdb27207362.jpg) | ![gasadalur](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498559-87eb6426-04d7-11e8-825c-2dd2abdfc112.jpg) |\n| ![dubai](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498466-1375b88a-04d7-11e8-8f8e-9d202da6a6b3.jpg) | ![dubai](https:\u002F\u002Fuser-images.githubusercontent.com\u002F883386\u002F35498827-8cee502c-04d8-11e8-8449-05805f196d60.jpg) |\n### Useful resources\n* https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FSeam_carving\n* https:\u002F\u002Finst.eecs.berkeley.edu\u002F~cs194-26\u002Ffa16\u002Fhw\u002Fproj4-seamcarving\u002Fimret.pdf\n* http:\u002F\u002Fpages.cs.wisc.edu\u002F~moayad\u002Fcs766\u002Fdownload_files\u002Falnammi_cs_766_final_report.pdf\n* https:\u002F\u002Fstacks.stanford.edu\u002Ffile\u002Fdruid:my512gb2187\u002FZargham_Nassirpour_Content_aware_image_resizing.pdf\n\n## Author\n\n* Endre Simo ([@simo_endre](https:\u002F\u002Ftwitter.com\u002Fsimo_endre))\n\n## License\n\nCopyright © 2018 Endre Simo\n\nThis project is under the MIT License. See the LICENSE file for the full license text.\n","Caire 是一个基于内容感知的图像缩放库。它利用了缝合雕刻算法，通过生成能量图（边缘检测）来识别图像中相对不重要的部分，并依据这些信息进行智能裁剪或扩展，以保持图像主要内容的完整性。该库支持自定义命令行操作、图形用户界面进度指示以及图像的缩小和放大处理。特别适用于需要高质量图像调整但又希望保留关键视觉元素的场景，如网页设计、移动应用开发及任何涉及动态图像尺寸调整的应用领域。采用Go语言编写，确保了良好的性能与跨平台兼容性。",2,"2026-06-11 03:02:11","top_language"]