{"id":15486893,"url":"https://github.com/codenoid/goimagemerge","last_synced_at":"2025-03-28T16:14:37.281Z","repository":{"id":100300636,"uuid":"421884095","full_name":"codenoid/goimagemerge","owner":"codenoid","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-27T16:02:11.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T16:19:43.537Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/codenoid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-10-27T16:00:38.000Z","updated_at":"2022-12-06T23:23:49.000Z","dependencies_parsed_at":"2023-05-13T14:15:28.657Z","dependency_job_id":null,"html_url":"https://github.com/codenoid/goimagemerge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenoid%2Fgoimagemerge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenoid%2Fgoimagemerge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenoid%2Fgoimagemerge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenoid%2Fgoimagemerge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codenoid","download_url":"https://codeload.github.com/codenoid/goimagemerge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246059336,"owners_count":20717085,"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":[],"created_at":"2024-10-02T06:20:20.658Z","updated_at":"2025-03-28T16:14:37.262Z","avatar_url":"https://github.com/codenoid.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## gim - Grid Based Image Merge Library (FORK)\n\n[github.com/ozankasikci/go-image-merge](github.com/ozankasikci/go-image-merge)\n\n`gim` is a image merging library that can accept image paths as input, read the image contents, add background color, draw layers on top of each other, merge them into a grid with the desired size.\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Examples](#examples)\n  * [Grid Unit Count - Vertical \u0026 Horizontal](#grid-unit-count---vertical--horizontal)\n  * [Grid Background Color](#grid-background-color)\n  * [Grid Layers - Draw Grids on top of Grids](#grid-layers---draw-grids-on-top-of-grids)\n- [Functional Options](#functional-options)\n- [TODO](#todo)\n\n## Installation\n\n`go get -u github.com/codenoid/goimagemerge`\n\n## Getting Started\n\nImport the library and give the image paths and grid size as the minimum required arguments.\n\nBasic usage:\n\n```go\nimport gim \"github.com/ozankasikci/go-image-merge\"\n\n// accepts *Grid instances, grid unit count x, grid unit count y\n// returns an *image.RGBA object\ngrids := []*gim.Grid{\n\t{ImageFilePath: \"file.jpg\"},\n\t{ImageFilePath: \"file.png\"},\n}\nrgba, err := gim.New(grids, 2, 1).Merge()\n\n// save the output to jpg or png\nfile, err := os.Create(\"file/path.jpg|png\")\nerr = jpeg.Encode(file, rgba, \u0026jpeg.Options{Quality: 80})\nerr = png.Encode(file, rgba)\n```\n\nSee [Examples](#examples) for available options and advanced usage.\n\n## Examples\n\n### Grid Unit Count - Vertical \u0026 Horizontal\n```go\ngrids := []*gim.Grid{\n    {ImageFilePath: \"./cmd/gim/input/kitten.jpg\"},\n    {ImageFilePath: \"./cmd/gim/input/kitten.jpg\"},\n    {ImageFilePath: \"./cmd/gim/input/kitten.jpg\"},\n    {ImageFilePath: \"./cmd/gim/input/kitten.jpg\"},\n}\nrgba, err := gim.New(grids, 2, 2).Merge()\n```\n\n#### Output\n![](https://raw.githubusercontent.com/ozankasikci/ozankasikci.github.io/master/gim/grid-size-2-2.jpg)\n\n### Grid Background Color\n```go\ngrids := []*gim.Grid{\n    {\n        ImageFilePath: \"./cmd/gim/input/ginger.png\",\n        BackgroundColor: color.White,\n    },\n    {\n        ImageFilePath: \"./cmd/gim/input/ginger.png\",\n        BackgroundColor: color.RGBA{R: 0x8b, G: 0xd0, B: 0xc6},\n    },\n}\nrgba, err := gim.New(grids, 2, 1).Merge()\n```\n\n#### Output\n![](https://raw.githubusercontent.com/ozankasikci/ozankasikci.github.io/master/gim/grid-bg-color.jpg)\n\n### Grid Layers - Draw Grids on top of Grids\n```go\ngrids := []*gim.Grid{\n    {\n        ImageFilePath: \"./cmd/gim/input/ginger.png\",\n        BackgroundColor: color.White,\n        // these grids will be drawn on top of the first grid\n        Grids: []*gim.Grid{\n            {\n            \tImageFilePath: \"./cmd/gim/input/tick.png\",\n            \tOffsetX: 50, OffsetY: 20,\n            },\n        },\n    },\n    {\n        ImageFilePath: \"./cmd/gim/input/ginger.png\",\n        BackgroundColor: color.RGBA{R: 0x8b, G: 0xd0, B: 0xc6},\n        // these grids will be drawn on top of the second grid\n        Grids: []*gim.Grid{\n            {\n            \tImageFilePath: \"./cmd/gim/input/tick.png\",\n            \tOffsetX: 200, OffsetY: 170,\n            },\n            {\n            \tImageFilePath: \"./cmd/gim/input/tick.png\",\n            \tOffsetX: 200, OffsetY: 20,\n            },\n        },\n    },\n}\nrgba, err := gim.New(grids, 2, 1).Merge()\n```\n\n#### Output\n![](https://raw.githubusercontent.com/ozankasikci/ozankasikci.github.io/master/gim/grid-layers.jpg)\n\n## Functional Options\n\n### OptBaseDir\n```go\n// you can omit the full path if you set a base dir\ngrids := []*gim.Grid{\n    {ImageFilePath: \"kitten.jpg\"},\n    {ImageFilePath: \"kitten.jpg\"},\n}\nrgba, err := gim.New(grids, 1, 2,\n\tgim.OptBaseDir(\"./cmd/gim/input\"),\n).Merge()\n```\n\n### OptGridSize\n```go\n// you can resize the grids in pixels\ngrids := []*gim.Grid{\n    {ImageFilePath: \"kitten.jpg\"},\n    {ImageFilePath: \"kitten.jpg\"},\n}\nrgba, err := gim.New( grids, 2, 1,\n\tgim.OptBaseDir(\"./cmd/gim\"),\n\tgim.OptGridSize(200,150),\n).Merge()\n```\n#### Output\n![](https://raw.githubusercontent.com/ozankasikci/ozankasikci.github.io/master/gim/grid-resize-pixels-200-150.jpg)\n\n## TODO\n- [x] Add colored background support\n- [ ] Add resize support (stretch, fit etc.)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenoid%2Fgoimagemerge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodenoid%2Fgoimagemerge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenoid%2Fgoimagemerge/lists"}