{"id":16163749,"url":"https://github.com/sug0/go-glitch","last_synced_at":"2025-07-04T06:09:56.145Z","repository":{"id":57509480,"uuid":"128487990","full_name":"sug0/go-glitch","owner":"sug0","description":"A go package to glitch images based on input expressions","archived":false,"fork":false,"pushed_at":"2021-04-30T14:12:17.000Z","size":39,"stargazers_count":7,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T19:51:42.486Z","etag":null,"topics":["art","glitch","go","golang","gopher","image","trippy"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sug0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-07T02:01:27.000Z","updated_at":"2024-12-04T03:02:14.000Z","dependencies_parsed_at":"2022-09-26T17:51:10.124Z","dependency_job_id":null,"html_url":"https://github.com/sug0/go-glitch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sug0/go-glitch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sug0%2Fgo-glitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sug0%2Fgo-glitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sug0%2Fgo-glitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sug0%2Fgo-glitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sug0","download_url":"https://codeload.github.com/sug0/go-glitch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sug0%2Fgo-glitch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263457206,"owners_count":23469297,"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":["art","glitch","go","golang","gopher","image","trippy"],"created_at":"2024-10-10T02:44:20.360Z","updated_at":"2025-07-04T06:09:55.823Z","avatar_url":"https://github.com/sug0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://u.sicp.me/k4Tum.png)\n\n# Go Glitch\n\nA go package to glitch an image based on an expression you pass in as input!\nThe only limit is your creativity (and patience)!\n\n## Discord\n\n[Join our discord server!](https://discord.gg/cUW4b6Z)\n\n    \n# What is the deal with the expressions?\n\nYou can think of the image as a functor that you map an expression to, for each pixel's component colors,\nreturning a new one. The allowed operators are:\n\n* `+` plus\n* `-` minus\n* `*` multiplication\n* `/` division\n* `%` modulo\n* `#` power of operator\n* `\u0026` bit and\n* `|` bit or\n* `:` bit and not\n* `^` bit xor\n* `\u003c` bit left shift\n* `\u003e` bit right shift\n* `?` returns 255 if left side is greater otherwise 0\n* `@` attributes a weight in the range `[0, 255]` to the value on the left\n\nThe expressions are made up of operators, numbers, parenthesis, and a set of parameters:\n\n* `c` the current value of each pixel component color\n* `b` the blurred version of `c`\n* `h` the horizontally flipped version of `c`\n* `v` the vertically flipped version of `c`\n* `d` the diagonally flipped version of `c`\n* `Y` the luminosity, or grayscale component of each pixel\n* `N` a noise pixel (i.e. a pixel where each component is a random value)\n* `R` the red color (i.e. rgb(255, 0, 0))\n* `G` the green color (i.e. rgb(0, 255, 0))\n* `B` the blue color (i.e. rgb(0, 0, 255))\n* `s` the value of each pixel's last saved evaluated expression\n* `r` a pixel made up of a random color component from the neighboring 8 pixels\n* `e` the difference of all pixels in a box, creating an edge-like effect\n* `x` the current x coordinate being evaluated normalized in the range `[0, 255]`\n* `y` the current y coordinate being evaluated normalized in the range `[0, 255]`\n* `H` the highest valued color component in the neighboring 8 pixels\n* `L` the lowest valued color component in the neighboring 8 pixels\n\n## Examples\n\n* `128 \u0026 (c - ((c - 150 + s) \u003e 5 \u003c s))`\n* `(c \u0026 (c ^ 55)) + 25`\n* `128 \u0026 (c + 255) : (s ^ (c ^ 255)) + 25`\n\nMore examples can be found\n[here](https://github.com/sugoiuguu/go-glitch/blob/master/res/cool.txt).\n\n\n# Command line tool usage\n\nUse the [docker image](https://hub.docker.com/r/sugoiuguu/go-glitch/):\n\n    $ docker run sugoiuguu/go-glitch\n\n\n# API usage\n\n```go\npackage main\n\nimport (\n    \"os\"\n    \"time\"\n    \"math/rand\"\n    \"image\"\n    \"image/png\"\n    _ \"image/jpeg\"\n\n    \"github.com/sugoiuguu/go-glitch\"\n)\n\nfunc main() {\n    f, err := os.Open(os.Args[2])\n    if err != nil {\n        panic(err)\n    }\n    defer f.Close()\n\n    f2, err := os.Create(os.Args[1])\n    if err != nil {\n        panic(err)\n    }\n    defer f2.Close()\n\n    img, _, err := image.Decode(f)\n    if err != nil {\n        panic(err)\n    }\n\n    rand.Seed(time.Now().UnixNano())\n\n    expr, err := glitch.CompileExpression(\"(n|(c \u003e 1)) ^ 128\")\n    if err != nil {\n        panic(err)\n    }\n\n    g, err := expr.JumblePixels(img)\n    if err != nil {\n        panic(err)\n    }\n    png.Encode(f2, g)\n}\n```\n\n# C/C++ interface\n\nThere is an experimental interface for C/C++ code\n[here](https://github.com/sugoiuguu/go-glitch/blob/master/example/ffi.go).\nThe API is:\n\n```c\ntypedef struct {\n    char *data;\n    size_t size;\n} Image_t;\n\nextern Image_t *jumble_pixels(char *expression, char *data, int size);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsug0%2Fgo-glitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsug0%2Fgo-glitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsug0%2Fgo-glitch/lists"}