{"id":16100639,"url":"https://github.com/0x61nas/aarty","last_synced_at":"2025-04-07T13:08:52.367Z","repository":{"id":60740569,"uuid":"545140604","full_name":"0x61nas/aarty","owner":"0x61nas","description":"Print any image in your terminal","archived":false,"fork":false,"pushed_at":"2024-08-30T00:25:25.000Z","size":13383,"stargazers_count":72,"open_issues_count":11,"forks_count":6,"subscribers_count":2,"default_branch":"aurora","last_synced_at":"2024-10-10T18:47:31.334Z","etag":null,"topics":["ansi","ascii","ascii-art","ascii-generator","ascii-generators","ascii-graphics","cli","command-line","convert-image-to-ascii","hacktoberfest","rust","text"],"latest_commit_sha":null,"homepage":"https://lib.rs/crates/aarty","language":"Rust","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/0x61nas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"polar":"0x61nas","buy_me_a_coffee":"0x61nas","liberapay":"0x61nas","ko_fi":"0x61nas"}},"created_at":"2022-10-03T21:17:51.000Z","updated_at":"2024-10-10T11:37:10.000Z","dependencies_parsed_at":"2024-02-02T17:26:33.428Z","dependency_job_id":"8d95f5ed-e351-4193-b465-278b7b0763a3","html_url":"https://github.com/0x61nas/aarty","commit_stats":null,"previous_names":["0x61nas/aarty","anas-elgarhy/aarty"],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Faarty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Faarty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Faarty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Faarty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0x61nas","download_url":"https://codeload.github.com/0x61nas/aarty/tar.gz/refs/heads/aurora","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657281,"owners_count":20974345,"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":["ansi","ascii","ascii-art","ascii-generator","ascii-generators","ascii-graphics","cli","command-line","convert-image-to-ascii","hacktoberfest","rust","text"],"created_at":"2024-10-09T18:47:31.845Z","updated_at":"2025-04-07T13:08:52.340Z","avatar_url":"https://github.com/0x61nas.png","language":"Rust","funding_links":["https://polar.sh/0x61nas","https://buymeacoffee.com/0x61nas","https://liberapay.com/0x61nas","https://ko-fi.com/0x61nas"],"categories":[],"sub_categories":[],"readme":"[![asciicast](https://asciinema.org/a/633827.svg)](https://asciinema.org/a/633827)\n\n## **aarty**\nmini freamwork to render images in the terminals/ttys.\n\n[![crates.io](https://img.shields.io/crates/v/aarty.svg)](https://crates.io/crates/aarty)\n[![docs.rs](https://docs.rs/aarty/badge.svg)](https://docs.rs/aarty)\n[![downloads](https://img.shields.io/crates/d/aarty.svg)](https://crates.io/crates/aarty)\n[![license](https://img.shields.io/crates/l/aarty.svg)](https://github.com/0x61nas/aarty/blob/aurora/LICENSE)\n\n## Examples\n```rust\nlet cfg = Config::new(vec![' ', '.', ',', '-', '~', '!', '*', '%', '$', '@', '#'].into());\n\nlet image = image::open(\"mylove.jpg\").unwrap();\nlet (w, h) = image.dimensions();\n\nlet mut out = BufWriter::with_capacity(cfg.calc_buf_size(w, h), io::stdout().lock());\n\nconvert_image_to_ascii(\u0026cfg, \u0026image, \u0026mut out).expect(\"IO error\");\n```\nEnable the foreground colors\n```rust\nlet cfg = Config::new(vec![' ', '.', ',', '-', '~', '!', '*', '%'].into()).with_flags(COLORS);\n\n// ...\n```\n\nReverse them with the background color\n```rust\nlet cfg = Config::new(Sympols::empty()).with_background((232, 209, 204)).with_flags(COLORS | REVERSE);\n\n// ...\n```\n\nIf you wanna build a rebresentesion in memory so you can modify it or use it multiple times, then you may found that implement [`FragmentWriter`]\nfor such a structher is useful.\n```rust\nstruct TerminalFrame {\n    fragments: Vec\u003c(char, ANSIColor)\u003e,\n   cfg: Config,\n}\n\nimpl FragmentWriter for TerminalFrame {\n    fn background(\u0026mut self, _: \u0026ANSIColor) -\u003e Result\u003cbool, Box\u003cdyn std::error::Error\u003e\u003e {\n        // Nah, I don't care, I have my configs :p\n        //  but pretent like if you care so it will skip the swap operation.\n        Ok(true)\n    }\n\n    fn write_fragment(\u0026mut self, info: FragmentInfo) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n        self.fragments.push((info.sym, info.fg));\n        Ok(())\n    }\n\n    fn write_colored_fragment(\n        \u0026mut self,\n        info: FragmentInfo,\n        _: Option\u003c\u0026ANSIColor\u003e,\n        _: Option\u003c\u0026ANSIColor\u003e,\n    ) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n        self.write_fragment(info)\n    }\n\n    fn write_bytes(\u0026mut self, _bytes: \u0026[u8]) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n        // Just ignore them\n        Ok(())\n    }\n}\n\n// So you can use it as a buffer\nlet cfg = Config::new(vec!['I', 'L', 'O', 'V', 'E', 'U'].into()).with_flags(COLORS);\n\nlet image = image::open(\"mylove.jpg\").unwrap();\nlet (w, h) = image.dimensions();\nlet mut frame = TerminalFrame {\n    fragments: Vec::with_capacity(w as usize * h as usize),\n    cfg: cfg.clone(),\n};\naarty::convert_image_to_ascii(\u0026cfg, \u0026image, \u0026mut frame).expect(\"Write error\");\n//  Do whatever you want with this object...\n```\n\nBut be aware by doing this, you'll have to implement the rendaring mechanism when its its the time to print the image (a.k.a. rendering it).\n\nFor such this case, we have [`TextImage`], which basically dose the same thing as the code above but in more ergnomic way, And it does implement the rendering mechanism, so you can just print it, and it will render the image properly.\nYou can enable this type with `text_image` feature, which is enabled by default.\n\nThe `text_image` feature also include the [`ToTextImage`] trait, which provide an ergonomic way to construct an [`TextImage`] object.\n```rust\nuse aarty::ToTextImage;\nlet cfg = Config::new_with_background(Sympols::empty(), (232, 209, 204).into()).with_flags(COLORS | REVERSE);\n\nlet image = image::open(\"mylove.jpg\").unwrap().to_text(cfg);\nprintln!(\"{image}\");\n```\n\u003e You have to enable the `image` feature for this to work.\n\n## The binary\nWe offer a simple binary that's implement the most of this crate features. You can build it with the build command or if u use cargo then you can install it via `cargo install aarty`.\n\n\u003e [!Note]\n\u003e for more information about the binary and how to use it, you can run `aarty --help` or see this [match](https://github.com/0x61nas/aarty/blob/aurora/src/bin/args.rs#L59).\n\n\n## Contributing\nI'm happy to accept any contributions, just consider reading the [CONTRIBUTING.md](https://github.com/0x61nas/aarty/blob/aurora/CONTRIBUTING.md) guide first.\n\n\u003e the main keywords are: **signed commits**, **conventional commits**, **no emojis**, **linear history**, **the PR shouldn't have more than tree commits most of the time**\n\n## License\nThis project is licensed under [MIT license][mit].\n\n[mit]: https://github.com/0x61nas/aarty/blob/aurora/LICENSE\n\n\n## Dependencies graph\n\n![deps graph](./_deps.png)\n\n\u003e Generated with [cargo-depgraph](https://crates.io/crates/cargo-depgraph)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x61nas%2Faarty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0x61nas%2Faarty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x61nas%2Faarty/lists"}