Skip to content

Commit

Permalink
Trim whitespace from base64 encoded image data before decoding it (#1…
Browse files Browse the repository at this point in the history
…9977)

Closes #17956
Closes #16330

This fix is for both REPL (released) and notebook (unreleased)

<img width="1210" alt="image"
src="https://github.com/user-attachments/assets/bd046f0f-3ad1-4c25-b3cb-114e008c2a69">

Release Notes:

- Fixed image support in REPL for certain versions of matplotlib that
included preceding and/or trailing whitespace in the base64 image data
  • Loading branch information
rgbkrk authored Oct 30, 2024
1 parent 60be47d commit 7ce131a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/repl/src/outputs/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct ImageView {

impl ImageView {
pub fn from(base64_encoded_data: &str) -> Result<Self> {
let bytes = BASE64_STANDARD.decode(base64_encoded_data)?;
let bytes = BASE64_STANDARD.decode(base64_encoded_data.trim())?;

let format = image::guess_format(&bytes)?;
let mut data = image::load_from_memory_with_format(&bytes, format)?.into_rgba8();
Expand Down

0 comments on commit 7ce131a

Please sign in to comment.