Skip to content

Commit

Permalink
Add saving plot as tiff (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtmok authored Oct 22, 2024
1 parent 654a0a6 commit 0ebe049
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/amalthea/src/comm/plot_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ pub enum RenderFormat {

#[serde(rename = "pdf")]
#[strum(to_string = "pdf")]
Pdf
Pdf,

#[serde(rename = "tiff")]
#[strum(to_string = "tiff")]
Tiff
}

/// Possible values for PlotUnit
Expand Down
6 changes: 6 additions & 0 deletions crates/amalthea/src/comm/ui_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ pub enum UiFrontendEvent {
#[serde(rename = "show_html_file")]
ShowHtmlFile(ShowHtmlFileParams),

/// This event is used to signal that the stored messages the front-end
/// replays when constructing multi-output plots should be reset. This
/// happens for things like a holoviews extension being changed.
#[serde(rename = "clear_webview_preloads")]
ClearWebviewPreloads,

}

/**
Expand Down
6 changes: 6 additions & 0 deletions crates/ark/src/modules/positron/graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ renderWithPlotDevice <- function(filepath, format, width, height, res, type ) {
res = res,
type = type
),
"tiff" = grDevices::tiff(
filename = filepath,
width = width,
height = height,
type = type
),
stop("Internal error: Unknown plot `format`.")
)
}
Expand Down
1 change: 1 addition & 0 deletions crates/ark/src/plots/graphics_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ impl DeviceContext {
RenderFormat::Svg => "image/svg+xml".to_string(),
RenderFormat::Pdf => "application/pdf".to_string(),
RenderFormat::Jpeg => "image/jpeg".to_string(),
RenderFormat::Tiff => "image/tiff".to_string(),
}
}

Expand Down

0 comments on commit 0ebe049

Please sign in to comment.