Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshuabrest/icns-rs
Create and parse Apple ICNS files rust
https://github.com/joshuabrest/icns-rs
apple icns rust
Last synced: 15 days ago
JSON representation
Create and parse Apple ICNS files rust
- Host: GitHub
- URL: https://github.com/joshuabrest/icns-rs
- Owner: JoshuaBrest
- License: lgpl-3.0
- Created: 2023-07-06T08:33:35.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-07-16T19:56:31.000Z (over 1 year ago)
- Last Synced: 2024-10-07T21:41:43.265Z (about 1 month ago)
- Topics: apple, icns, rust
- Language: Rust
- Homepage:
- Size: 289 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# icns-rs
The ICNS format is a file format used by Apple to store icons for macOS applications. This crate provides a simple API for reading and (and soon)writing ICNS files.
## Roadmap
- [x] Write ICNS files
- [ ] Read ICNS files## Usage
Here's a simple example of how to read an ICNS file:
> You can find this example in `examples/encode.rs` or run it with:
> ```sh
> cargo run --example encode
> ``````rust
use std::fs::File;
use std::io::prelude::*;
use image::open;
use icns_rs::{IcnsEncoder, IconFormats};fn main() -> std::io::Result<()> {
// Open the image
let image = match open("example.png") {
Ok(image) => image,
Err(e) => {
println!("Error opening file: {}", e);
return Ok(());
}
};// Create the encoder
let mut encoder = IcnsEncoder::new();encoder.data(image);
encoder.formats(IconFormats::recommended());// Encode the image
let data = match encoder.build() {
Ok(data) => data,
Err(e) => {
println!("Error encoding image: {}", e);
return Ok(());
}
};// Write data to file
let mut file = File::create("example.icns")?;
file.write_all(&data)?;Ok(())
}
```## License
This project is licensed under the GPLv3 license. See the [LICENSE](LICENSE) file for more details.
## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
## Acknowledgements
This project is heavily inspired by:
- The Python package: [icnsutil](https://github.com/relikd/icnsutil/)
- The JavaScript package: [@fiahfy/icns](https://github.com/fiahfy/icns/)
- The JavaScript PackBits implementation: [@fiahfy/packbits](https://github.com/fiahfy/packbits/)
- The Wikipedia page: [Wikipedia: Apple Icon Image Format](https://en.wikipedia.org/wiki/Apple_Icon_Image_format#Icon_types)When I started building this, I didn't know there already was a ICNS lib for rust, but, after looking at it, it was not up to my standards because of the lack of ARGB, RGB, and, Mask support. I wanted to create a modern package that was easy to use and had a simple API. I also wanted to make sure that it was well documented and had a good test suite. I hope you enjoy using this package as much as I enjoyed making it!.