{"id":13413201,"url":"https://github.com/disintegration/imaging","last_synced_at":"2025-05-10T09:13:36.069Z","repository":{"id":5826814,"uuid":"7042338","full_name":"disintegration/imaging","owner":"disintegration","description":"Imaging is a simple image processing package for Go","archived":false,"fork":false,"pushed_at":"2023-09-21T02:16:10.000Z","size":3677,"stargazers_count":5458,"open_issues_count":33,"forks_count":461,"subscribers_count":80,"default_branch":"master","last_synced_at":"2025-05-10T09:13:32.551Z","etag":null,"topics":["blur","brightness","contrast","convolution","crop","gamma","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/disintegration.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}},"created_at":"2012-12-06T20:21:21.000Z","updated_at":"2025-05-09T11:41:49.000Z","dependencies_parsed_at":"2022-07-12T15:03:04.799Z","dependency_job_id":"cceac1db-ec48-4818-bb76-2832a869f813","html_url":"https://github.com/disintegration/imaging","commit_stats":{"total_commits":183,"total_committers":19,"mean_commits":9.631578947368421,"dds":0.4316939890710383,"last_synced_commit":"d40f48ce0f098c53ab1fcd6e0e402da682262da5"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disintegration%2Fimaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disintegration%2Fimaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disintegration%2Fimaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disintegration%2Fimaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/disintegration","download_url":"https://codeload.github.com/disintegration/imaging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253391773,"owners_count":21900957,"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","contrast","convolution","crop","gamma","image","resize","rotate","sharpness"],"created_at":"2024-07-30T20:01:35.037Z","updated_at":"2025-05-10T09:13:36.048Z","avatar_url":"https://github.com/disintegration.png","language":"Go","readme":"# Imaging\r\n\r\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/disintegration/imaging)](https://pkg.go.dev/github.com/disintegration/imaging)\r\n[![Build Status](https://travis-ci.org/disintegration/imaging.svg?branch=master)](https://travis-ci.org/disintegration/imaging)\r\n[![Coverage Status](https://coveralls.io/repos/github/disintegration/imaging/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/disintegration/imaging?branch=master)\r\n[![Go Report Card](https://goreportcard.com/badge/github.com/disintegration/imaging)](https://goreportcard.com/report/github.com/disintegration/imaging)\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## Installation\r\n\r\n    go get -u github.com/disintegration/imaging\r\n\r\n## Documentation\r\n\r\nhttps://pkg.go.dev/github.com/disintegration/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### 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### What's the difference between `imaging` and `gift` packages?\r\n\r\n[imaging](https://github.com/disintegration/imaging)\r\nis designed to be a lightweight and simple image manipulation package.\r\nIt provides basic image processing functions and a few helper functions\r\nsuch as `Open` and `Save`. It consistently returns *image.NRGBA image \r\ntype (8 bits per channel, RGBA).\r\n\r\n[gift](https://github.com/disintegration/gift)\r\nsupports more advanced image processing, for example, sRGB/Linear color\r\nspace conversions. It also supports different output image types\r\n(e.g. 16 bits per channel) and provides easy-to-use API for chaining\r\nmultiple processing steps together.\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/disintegration/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","funding_links":[],"categories":["开源类库","Misc","Images","Go","图片","Programming","圖象","Open source library","Imagery","Images 图像处理","Relational Databases","图像","图片处理","\u003cspan id=\"图片-images\"\u003e图片 Images\u003c/span\u003e"],"sub_categories":["图形处理","Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","Golang","高級控制台界面","Graphics Processing","Middlewares","SQL 查询语句构建库","交流","高级控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisintegration%2Fimaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisintegration%2Fimaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisintegration%2Fimaging/lists"}