{"id":22431196,"url":"https://github.com/henrixounez/vpng","last_synced_at":"2026-01-06T21:45:25.169Z","repository":{"id":39621441,"uuid":"303000321","full_name":"Henrixounez/vpng","owner":"Henrixounez","description":"V PNG Image Processing","archived":false,"fork":false,"pushed_at":"2024-06-26T16:05:21.000Z","size":77,"stargazers_count":15,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T12:26:27.834Z","etag":null,"topics":["image","image-processing","png","v","vlang"],"latest_commit_sha":null,"homepage":"","language":"V","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/Henrixounez.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":"2020-10-10T22:27:29.000Z","updated_at":"2024-09-22T02:31:24.000Z","dependencies_parsed_at":"2024-06-26T19:27:55.732Z","dependency_job_id":"ebc5ca21-86c3-43bf-a043-9ab3c3d8a7e5","html_url":"https://github.com/Henrixounez/vpng","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/Henrixounez%2Fvpng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henrixounez%2Fvpng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henrixounez%2Fvpng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henrixounez%2Fvpng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Henrixounez","download_url":"https://codeload.github.com/Henrixounez/vpng/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245799068,"owners_count":20674088,"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":["image","image-processing","png","v","vlang"],"created_at":"2024-12-05T21:22:15.912Z","updated_at":"2026-01-06T21:45:25.137Z","avatar_url":"https://github.com/Henrixounez.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **V-PNG**: V PNG Image Processing\n\n## How to use :\n\nIts **simple**, download the module and then you just have to do :\n```v\nimport vpng\n\npng_file := vpng.read(\"image.png\") or { return }\npng_file.write(\"output.png\")\n```\n\n\u003cbr/\u003e\n\u003chr/\u003e\n\u003cbr/\u003e\n\n## Tips\n\n\u003cbr/\u003e\n\nTo deal with the different kinds of `Pixel`, (cf: [Pixel Types](###pixel-types)) the prefered method is :\n```v\npixel := png_file.pixels[i]\nmatch pixel {\n    vpng.Grayscale {\n        ...\n    }\n    vpng.TrueColor {\n        ...\n    }\n    ...\n    ...\n}\n```\n\n\u003cbr/\u003e\n\u003chr/\u003e\n\u003cbr/\u003e\n\n## Methods\n| Method | use |\n|-|-|\n| `read(filename string) ?PngFile` | Parses the given `filename` png file and returns an optional `PngFile`. |\n| `(PngFile).write(filename string)` | Writes the given `PngFile` in the `filename` png file.\n\n\u003cbr/\u003e\n\n## Types\n\n### Structure\n- `PngFile`, Object returned by the `.parse` function. Contains all useful information about the parsed png file :\n    ```v\n    pub struct PngFile {\n        ihdr       IHDR\n    pub:\n        width      int          // Width of image\n        height     int          // Height of image\n        pixel_type PixelType    // Pixels type\n    pub mut:\n        pixels     []Pixel      // Modifiable pixel array\n    }\n    ```\n\n### Pixel Types\n- `PixelType`, Enum for type of pixel possible in the PngFile :\n    ```v\n    pub enum PixelType {\n        indexed\n        grayscale\n        grayscalealpha\n        truecolor\n        truecoloralpha\n    }\n    ```\n- `PixelType`, Generic type for the different possible types of pixels : \n    ```v\n    pub type Pixel = Grayscale | GrayscaleAlpha | Indexed |     TrueColor | TrueColorAlpha\n    ```\n- `Pixel`s :\n    - Indexed (*Not supported yet*) :\n        ```v\n        pub struct Indexed {\n        pub mut:\n            index byte\n        }\n        ```\n    - Grayscale (*Not supported yet*) :\n        ```v\n        pub struct Grayscale {\n        pub mut:\n            gray byte\n        }\n        ```\n    - GrayscaleAlpha (*Not supported yet*) :\n        ```v\n        pub struct GrayscaleAlpha {\n        pub mut:\n            gray  byte\n            alpha byte\n        }\n        ```\n    - TrueColor (RGB) :\n        ```v\n        pub struct TrueColor {\n        pub mut:\n            red   byte\n            green byte\n            blue  byte\n        }\n        ```\n    - TrueColorAlpha (RGBA) :\n        ```v\n        pub struct TrueColorAlpha {\n        pub mut:\n            red   byte\n            green byte\n            blue  byte\n            alpha byte\n        }\n        ```\n\n\u003cbr/\u003e\n\u003chr/\u003e\n\u003cbr/\u003e\n\n## Examples:\n- `png-printer.v`: Give it a `.png` file and it will print it for you in the terminal.\n- `redline.v`: Give it an input `.png` file and an output `.png` file. It will read the input, add a diagonal red line and write the result on the output file.\n\n### How to compile them from GitHub repository:\n```bash\n[vpng]$ v examples/png-printer.v -path \"..|@vlib|@vmodules\"\n```\n\n\u003cbr/\u003e\n\u003chr/\u003e\n\u003cbr/\u003e\n\n## Todo :\n- [ ] Handle all types of colors\n    - [x] Indexed\n    - [ ] Grayscale\n    - [ ] GrayscaleAlpha\n    - [x] TrueColor\n    - [x] TrueColorAlpha\n- [ ] Functions to easily manipulate the pixels / image, for example :\n    - [ ] Resize\n    - [x] Mirror\n    - [x] Rotate\n    - [ ] Zoom\n    - [ ] Slide\n    - [ ] Crop\n    - [x] Invert colors\n    - [ ] Change colors\n    - [ ] ...\n- [x] Write a png file (*Might be hard to have an optimized one*)\n    - [ ] Optimize it\n    - [ ] Filter pixels lines\n    - [ ] Group IDAT in chunks\n    - [ ] Save metadata\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrixounez%2Fvpng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenrixounez%2Fvpng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrixounez%2Fvpng/lists"}