{"id":17882159,"url":"https://github.com/nao1215/imaging","last_synced_at":"2025-03-22T12:31:33.437Z","repository":{"id":175559018,"uuid":"654100100","full_name":"nao1215/imaging","owner":"nao1215","description":"Imaging is a simple image processing package for Go","archived":false,"fork":false,"pushed_at":"2024-05-06T20:48:44.000Z","size":2664,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-08T02:52:32.789Z","etag":null,"topics":["blur","brightness","convolution","cotrast","crop","forked-repo","gamma","golang","image","resize","rotate","sharpness"],"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/nao1215.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":"2023-06-15T11:41:40.000Z","updated_at":"2024-05-08T02:52:34.144Z","dependencies_parsed_at":"2023-09-30T11:03:38.745Z","dependency_job_id":"9235485e-2b72-43f7-b5b3-c366d7f767bd","html_url":"https://github.com/nao1215/imaging","commit_stats":{"total_commits":77,"total_committers":2,"mean_commits":38.5,"dds":"0.051948051948051965","last_synced_commit":"36c33f7b16295f9c723340545bcf33a2c5fca376"},"previous_names":["nao1215/imaging","go-spectest/imaging"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fimaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fimaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fimaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fimaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nao1215","download_url":"https://codeload.github.com/nao1215/imaging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959443,"owners_count":20538625,"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":["blur","brightness","convolution","cotrast","crop","forked-repo","gamma","golang","image","resize","rotate","sharpness"],"created_at":"2024-10-28T12:48:26.090Z","updated_at":"2025-03-22T12:31:32.308Z","avatar_url":"https://github.com/nao1215.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub](https://img.shields.io/github/license/nao1215/imaging?style=flat-square)\r\n[![Go Reference](https://pkg.go.dev/badge/github.com/nao1215/imaging.svg)](https://pkg.go.dev/github.com/nao1215/imaging)\r\n![Coverage](https://raw.githubusercontent.com/nao1215/octocovs-central-repo/main/badges/nao1215/imaging/coverage.svg)\r\n[![LinuxUnitTest](https://github.com/nao1215/imaging/actions/workflows/linux_test.yml/badge.svg)](https://github.com/nao1215/imaging/actions/workflows/linux_test.yml)\r\n[![MacUnitTest](https://github.com/nao1215/imaging/actions/workflows/mac_test.yml/badge.svg)](https://github.com/nao1215/imaging/actions/workflows/mac_test.yml)\r\n[![WindowsUnitTest](https://github.com/nao1215/imaging/actions/workflows/windows_test.yml/badge.svg)](https://github.com/nao1215/imaging/actions/workflows/windows_test.yml)\r\n[![Go Report Card](https://goreportcard.com/badge/github.com/nao1215/imaging)](https://goreportcard.com/report/github.com/nao1215/imaging)\r\n[![reviewdog](https://github.com/nao1215/imaging/actions/workflows/reviewdog.yml/badge.svg)](https://github.com/nao1215/imaging/actions/workflows/reviewdog.yml)\r\n\r\n# Imaging\r\n**This Repository is forked from [disintegration/imaging](https://github.com/disintegration/imaging).** The reason why I forked it is that the original version has been slowly updated. This repository makes bug fixes and multi-platforming.\r\n\r\nPackage imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.).\r\n\r\nAll the image processing functions provided by the package accept any image type that implements `image.Image` interface\r\nas an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, non-premultiplied alpha).\r\n\r\n## Support OS / Go version\r\nThe following platforms and go versions have been unit tested.\r\n- Linux\r\n- Mac\r\n- Windows\r\n- Go ver 1.16 to 1.20\r\n\r\n## Documentation\r\n\r\nhttps://pkg.go.dev/github.com/nao1215/imaging\r\n\r\n## Usage examples\r\n\r\nA few usage examples can be found below. See the documentation for the full list of supported functions.\r\n\r\n### Sample command: gina\r\nAs a sample implementation of the nao1215/imaging package, I have prepared the **[gina](cmd/gina/README.md)** command.\r\n\r\n### Image resizing\r\n\r\n```go\r\n// Resize srcImage to size = 128x128px using the Lanczos filter.\r\ndstImage128 := imaging.Resize(srcImage, 128, 128, imaging.Lanczos)\r\n\r\n// Resize srcImage to width = 800px preserving the aspect ratio.\r\ndstImage800 := imaging.Resize(srcImage, 800, 0, imaging.Lanczos)\r\n\r\n// Scale down srcImage to fit the 800x600px bounding box.\r\ndstImageFit := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)\r\n\r\n// Resize and crop the srcImage to fill the 100x100px area.\r\ndstImageFill := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos)\r\n```\r\n\r\nImaging supports image resizing using various resampling filters. The most notable ones:\r\n- `Lanczos` - A high-quality resampling filter for photographic images yielding sharp results.\r\n- `CatmullRom` - A sharp cubic filter that is faster than Lanczos filter while providing similar results.\r\n- `MitchellNetravali` - A cubic filter that produces smoother results with less ringing artifacts than CatmullRom.\r\n- `Linear` - Bilinear resampling filter, produces smooth output. Faster than cubic filters.\r\n- `Box` - Simple and fast averaging filter appropriate for downscaling. When upscaling it's similar to NearestNeighbor.\r\n- `NearestNeighbor` - Fastest resampling filter, no antialiasing.\r\n\r\nThe full list of supported filters:  NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. Custom filters can be created using ResampleFilter struct.\r\n\r\n**Resampling filters comparison**\r\n\r\nOriginal image:\r\n\r\n![srcImage](testdata/branches.png)\r\n\r\nThe same image resized from 600x400px to 150x100px using different resampling filters.\r\nFrom faster (lower quality) to slower (higher quality):\r\n\r\nFilter                    | Resize result\r\n--------------------------|---------------------------------------------\r\n`imaging.NearestNeighbor` | ![dstImage](testdata/out_resize_nearest.png)\r\n`imaging.Linear`          | ![dstImage](testdata/out_resize_linear.png)\r\n`imaging.CatmullRom`      | ![dstImage](testdata/out_resize_catrom.png)\r\n`imaging.Lanczos`         | ![dstImage](testdata/out_resize_lanczos.png)\r\n\r\n\r\n### Gaussian Blur\r\n\r\n```go\r\ndstImage := imaging.Blur(srcImage, 0.5)\r\n```\r\n\r\nSigma parameter allows to control the strength of the blurring effect.\r\n\r\nOriginal image                     | Sigma = 0.5                            | Sigma = 1.5\r\n-----------------------------------|----------------------------------------|---------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_blur_0.5.png) | ![dstImage](testdata/out_blur_1.5.png)\r\n\r\n### Sharpening\r\n\r\n```go\r\ndstImage := imaging.Sharpen(srcImage, 0.5)\r\n```\r\n\r\n`Sharpen` uses gaussian function internally. Sigma parameter allows to control the strength of the sharpening effect.\r\n\r\nOriginal image                     | Sigma = 0.5                               | Sigma = 1.5\r\n-----------------------------------|-------------------------------------------|------------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_sharpen_0.5.png) | ![dstImage](testdata/out_sharpen_1.5.png)\r\n\r\n### Gamma correction\r\n\r\n```go\r\ndstImage := imaging.AdjustGamma(srcImage, 0.75)\r\n```\r\n\r\nOriginal image                     | Gamma = 0.75                             | Gamma = 1.25\r\n-----------------------------------|------------------------------------------|-----------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_gamma_0.75.png) | ![dstImage](testdata/out_gamma_1.25.png)\r\n\r\n### Contrast adjustment\r\n\r\n```go\r\ndstImage := imaging.AdjustContrast(srcImage, 20)\r\n```\r\n\r\nOriginal image                     | Contrast = 15                              | Contrast = -15\r\n-----------------------------------|--------------------------------------------|-------------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_contrast_p15.png) | ![dstImage](testdata/out_contrast_m15.png)\r\n\r\n### Brightness adjustment\r\n\r\n```go\r\ndstImage := imaging.AdjustBrightness(srcImage, 20)\r\n```\r\n\r\nOriginal image                     | Brightness = 10                              | Brightness = -10\r\n-----------------------------------|----------------------------------------------|---------------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_brightness_p10.png) | ![dstImage](testdata/out_brightness_m10.png)\r\n\r\n### Saturation adjustment\r\n\r\n```go\r\ndstImage := imaging.AdjustSaturation(srcImage, 20)\r\n```\r\n\r\nOriginal image                     | Saturation = 30                              | Saturation = -30\r\n-----------------------------------|----------------------------------------------|---------------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_saturation_p30.png) | ![dstImage](testdata/out_saturation_m30.png)\r\n\r\n### Hue adjustment\r\n\r\n```go\r\ndstImage := imaging.AdjustHue(srcImage, 20)\r\n```\r\n\r\nOriginal image                     | Hue = 60                                     | Hue = -60\r\n-----------------------------------|----------------------------------------------|---------------------------------------------\r\n![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_hue_p60.png) | ![dstImage](testdata/out_hue_m60.png)\r\n\r\n## FAQ\r\n\r\n### Incorrect image orientation after processing (e.g. an image appears rotated after resizing)\r\n\r\nMost probably, the given image contains the EXIF orientation tag.\r\nThe standard `image/*` packages do not support loading and saving\r\nthis kind of information. To fix the issue, try opening images with\r\nthe `AutoOrientation` decode option. If this option is set to `true`,\r\nthe image orientation is changed after decoding, according to the\r\norientation tag (if present). Here's the example:\r\n\r\n```go\r\nimg, err := imaging.Open(\"test.jpg\", imaging.AutoOrientation(true))\r\n```\r\n\r\n## Example code\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"image\"\r\n\t\"image/color\"\r\n\t\"log\"\r\n\r\n\t\"github.com/nao1215/imaging\"\r\n)\r\n\r\nfunc main() {\r\n\t// Open a test image.\r\n\tsrc, err := imaging.Open(\"testdata/flowers.png\")\r\n\tif err != nil {\r\n\t\tlog.Fatalf(\"failed to open image: %v\", err)\r\n\t}\r\n\r\n\t// Crop the original image to 300x300px size using the center anchor.\r\n\tsrc = imaging.CropAnchor(src, 300, 300, imaging.Center)\r\n\r\n\t// Resize the cropped image to width = 200px preserving the aspect ratio.\r\n\tsrc = imaging.Resize(src, 200, 0, imaging.Lanczos)\r\n\r\n\t// Create a blurred version of the image.\r\n\timg1 := imaging.Blur(src, 5)\r\n\r\n\t// Create a grayscale version of the image with higher contrast and sharpness.\r\n\timg2 := imaging.Grayscale(src)\r\n\timg2 = imaging.AdjustContrast(img2, 20)\r\n\timg2 = imaging.Sharpen(img2, 2)\r\n\r\n\t// Create an inverted version of the image.\r\n\timg3 := imaging.Invert(src)\r\n\r\n\t// Create an embossed version of the image using a convolution filter.\r\n\timg4 := imaging.Convolve3x3(\r\n\t\tsrc,\r\n\t\t[9]float64{\r\n\t\t\t-1, -1, 0,\r\n\t\t\t-1, 1, 1,\r\n\t\t\t0, 1, 1,\r\n\t\t},\r\n\t\tnil,\r\n\t)\r\n\r\n\t// Create a new image and paste the four produced images into it.\r\n\tdst := imaging.New(400, 400, color.NRGBA{0, 0, 0, 0})\r\n\tdst = imaging.Paste(dst, img1, image.Pt(0, 0))\r\n\tdst = imaging.Paste(dst, img2, image.Pt(0, 200))\r\n\tdst = imaging.Paste(dst, img3, image.Pt(200, 0))\r\n\tdst = imaging.Paste(dst, img4, image.Pt(200, 200))\r\n\r\n\t// Save the resulting image as JPEG.\r\n\terr = imaging.Save(dst, \"testdata/out_example.jpg\")\r\n\tif err != nil {\r\n\t\tlog.Fatalf(\"failed to save image: %v\", err)\r\n\t}\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n![dstImage](testdata/out_example.jpg)\r\n\r\n## License\r\nThe imaging library is licensed under the [MIT License](LICENSE).\r\nOriginal author: [Disintegration](https://github.com/disintegration)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnao1215%2Fimaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnao1215%2Fimaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnao1215%2Fimaging/lists"}