Skip to content

Commit

Permalink
rayimage v0.14.3: Fix add_title() when image is a filename
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermorganwall committed Dec 23, 2024
1 parent 394f2a2 commit 79f7d93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rayimage
Type: Package
Title: Image Processing for Simulated Cameras
Version: 0.14.2
Version: 0.14.3
Authors@R: c(person("Tyler", "Morgan-Wall", email = "[email protected]",
role = c("aut", "cph", "cre"), comment = c(ORCID = "0000-0002-3131-3814")),
person("Sean", "Barrett", role = c("ctb", "cph")))
Expand Down
17 changes: 14 additions & 3 deletions R/add_title.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
#'add_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20, title_bar_alpha = 0.8,
#' title_bar_color="red", title_color = "white")
#'}
#'if(run_documentation()){
#' #Read directly from a file
#' temp_image = tempfile(fileext = ".png")
#' ray_write_image(dragon, temp_image)
#' add_title(temp_image, preview = TRUE, title_text = "Dragon", title_size=20, title_bar_alpha = 0.8,
#' title_bar_color="red", title_color = "white")
#'}
add_title = function(image,
title_text = "", title_size = 30,
title_offset = rep(title_size/2,2),
Expand All @@ -83,8 +90,12 @@ add_title = function(image,
filename = NULL, preview = FALSE) {
imagetype = get_file_type(image)
temp = tempfile(fileext = ".png")
ray_write_image(image, temp)
temp_image = png::readPNG(temp)
if(imagetype %in% c("matrix", "array")) {
ray_write_image(image, temp)
temp_image = png::readPNG(temp)
} else {
temp_image = image
}

if(use_magick) {
if(title_style == "plain") {
Expand Down Expand Up @@ -265,7 +276,7 @@ add_title = function(image,
warning("Title position is ignored when not using {magick}")
}
draw_title_card(
temp_image,
ray_read_image(temp_image),
title = title_text,
padding_x = title_offset[1], padding_y = title_offset[2],
gp_text = grid::gpar(col = title_color,
Expand Down

0 comments on commit 79f7d93

Please sign in to comment.