{"id":17189093,"url":"https://github.com/esimov/gomp","last_synced_at":"2025-04-13T19:23:14.568Z","repository":{"id":62821724,"uuid":"558229878","full_name":"esimov/gomp","owner":"esimov","description":"Alpha compositing operations and blending modes in Go.","archived":false,"fork":false,"pushed_at":"2024-10-24T07:09:40.000Z","size":5880,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T10:03:36.053Z","etag":null,"topics":["alpha-compositing","blend-modes","colors","go","golang","image-composition","image-processing","porter-duff","rgba"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esimov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"esimov"}},"created_at":"2022-10-27T06:17:49.000Z","updated_at":"2025-02-17T01:21:28.000Z","dependencies_parsed_at":"2024-06-21T11:44:34.741Z","dependency_job_id":"00f4316c-a18d-4ec5-b21b-6f086b055196","html_url":"https://github.com/esimov/gomp","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":0.04878048780487809,"last_synced_commit":"66835c9109175b855779280196a8150b6314d54b"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgomp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgomp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgomp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgomp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esimov","download_url":"https://codeload.github.com/esimov/gomp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766687,"owners_count":21158302,"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":["alpha-compositing","blend-modes","colors","go","golang","image-composition","image-processing","porter-duff","rgba"],"created_at":"2024-10-15T01:10:43.606Z","updated_at":"2025-04-13T19:23:14.544Z","avatar_url":"https://github.com/esimov.png","language":"Go","funding_links":["https://github.com/sponsors/esimov"],"categories":[],"sub_categories":[],"readme":"# gomp\n[![CI](https://github.com/esimov/gomp/actions/workflows/ci.yml/badge.svg)](https://github.com/esimov/gomp/actions/workflows/ci.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/esimov/gomp)](https://goreportcard.com/report/github.com/esimov/gomp)\n[![go.dev reference](https://img.shields.io/badge/pkg.go.dev-reference-007d9c?logo=go)](https://pkg.go.dev/github.com/esimov/gomp)\n[![release](https://img.shields.io/badge/release-v1.0.2-blue.svg)](https://github.com/esimov/gomp/releases/tag/v1.0.2)\n[![license](https://img.shields.io/github/license/esimov/gomp)](./LICENSE)\n\nGo library for image blending and alpha compositing using advanced features like the Porter-Duff operator and blending modes.\n\n## About\n\nThe reason why this package has been developed is because the [**`image/draw`**](https://pkg.go.dev/image/draw) package from Go's standard library defines only one operation: drawing a source image onto the destination image, through an optional image mask. This is performed pixel by pixel and it's based on the classic \"[Compositing Digital Images](https://dl.acm.org/doi/pdf/10.1145/964965.808606)\" paper by Porter and Duff. This paper presented **12 different** composition operation, but the Draw method uses only two of them: `source over destination` and `source`.\n\nWhen dealing with image composition this is simply not enough. This library aims to overcome this deficiency by integrating the missing operators.\n\n| Alpha compositing\n|:--:\n| ![compositing](https://github.com/esimov/gomp/blob/master/examples/comp/composite.png) |\n\n### Blending modes\nFor convenience, this package implements also some of the most used blending modes in Photoshop. Similarly to the alpha compositing, blending modes defines the result of compositing a source and a destination but without being constrained to the alpha channel. The implementation follows the blending formulas presented in the W3C document: [Compositing and Blending](https://www.w3.org/TR/compositing-1/#blending). These blending modes are not covered by Porter and Duff, but have been included into this package for convenience.\n\n| Blending modes\n|:--:\n| ![blending](https://github.com/esimov/gomp/blob/master/examples/blend/blend.png) |\n\n## Installation\n```bash\n$ go install github.com/esimov/gomp@latest\n```\n\n## API\nThe API of the library is inspired by the [PorterDuff.Mode](https://developer.android.com/reference/android/graphics/PorterDuff.Mode) class from the Android SDK.\n\n### Alpha compositing\n```go\nop := gomp.InitOp()\nop.Set(gomp.SrcOver)\nbmp := gomp.NewBitmap(image.Rect(0, 0, size, size))\nimop.Draw(bmp, source, backdrop, nil)\n```\n\n### Blending modes\n```go\nop := gomp.NewBlend()\nop.Set(gomp.Multiply)\nbmp := gomp.NewBitmap(image.Rect(0, 0, size, size))\nimop.Draw(bmp, source, backdrop, op)\n```\n\nYou can combine the alpha compositing with blending modes at the same step, you just need to replace the last parameter of the `Draw` method with the initialized blending operation.\n\n### Alpha compositing and blending modes combined\n```go\nimop := gomp.InitOp()\nblop := gomp.NewBlend()\nblop.Set(gomp.Multiply)\nimop.Set(gomp.SrcOver)\nbmp := gomp.NewBitmap(image.Rect(0, 0, size, size))\nimop.Draw(bmp, srcImg, bgr, blop)\n```\n\n### Operators\n\n| Image compositing | Separable blending modes | Non-separable blending modes\n|:--:|:--:|:--:\n| `Clear` | `Normal` | `Hue` |\n| `Copy` | `Darken` | `Saturation` |\n| `Dst` | `Lighten` | `ColorMode` |\n| `SrcOver` | `Multiply` | `Luminosity` |\n| `DstOver` | `Screen` |\n| `SrcIn` | `Overlay` |\n| `DstIn` | `SoftLight` |\n| `SrcOut` | `HardLight` |\n| `DstOut` | `ColorDodge` |\n| `SrcAtop` | `ColorBurn` |\n| `DstAtop` | `Difference` |\n|  | `Exclusion` |\n\n### Examples\nThe images used in this document for visualizing the alpha compositing operation and the blending modes have been generated using this library. They can be found in the [examples](https://github.com/esimov/gomp/tree/master/examples) folder.\n\n## Author\n* Endre Simo ([@simo_endre](https://twitter.com/simo_endre))\n\n## License\nCopyright © 2022 Endre Simo\n\nThis software is distributed under the MIT license. See the [LICENSE](https://github.com/esimov/gomp/blob/master/LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesimov%2Fgomp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesimov%2Fgomp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesimov%2Fgomp/lists"}