-
Notifications
You must be signed in to change notification settings - Fork 13
Document the image feature flag, and converting to a base64 png. #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
dessalines
commented
Oct 20, 2025
- Fixes How do convert the decoded result to a base64 encoded image? #23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran prettier on this file also.
rubdos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also noticed now that decode_image is not shown in docs.
README.md
Outdated
| If you'd like to convert this image to a base64 `png`, you can add the `base64` and `image` crates, then do: | ||
|
|
||
| ```rust | ||
| use base64::{engine::general_purpose, Engine as _}; | ||
| use std::io::Cursor; | ||
|
|
||
| let mut bytes: Vec<u8> = Vec::new(); | ||
| image_buffer.write_to(&mut Cursor::new(&mut bytes), image::ImageOutputFormat::Png).unwrap(); | ||
|
|
||
| let b64_png = general_purpose::STANDARD.encode(bytes); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't include this. The whole purpose of blurhash is to have a succinct representation of an image, and this method does the exact opposite: it decodes our succinct representation into an image, then recompresses as a png, and then blows up the file through base64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K, removed that block now.
src/lib.rs
Outdated
| //! If you'd like to convert this image to a base64 `png`, you can add the `base64` and `image` crates, then do: | ||
| //! | ||
| //! ```no_run | ||
| //! use base64::{engine::general_purpose, Engine as _}; | ||
| //! use std::io::Cursor; | ||
| //! | ||
| //! let mut bytes: Vec<u8> = Vec::new(); | ||
| //! image_buffer.write_to(&mut Cursor::new(&mut bytes), image::ImageOutputFormat::Png).unwrap(); | ||
| //! | ||
| //! let b64_png = general_purpose::STANDARD.encode(bytes); | ||
| //! ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. This is not an approach I want to recommend to users of this crate.
Co-authored-by: Ruben De Smet <[email protected]>