Skip to content
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

Format Images inside Cells email output #1581

Open
2 tasks done
Amaru6 opened this issue Feb 16, 2024 · 0 comments
Open
2 tasks done

Format Images inside Cells email output #1581

Amaru6 opened this issue Feb 16, 2024 · 0 comments
Assignees

Comments

@Amaru6
Copy link

Amaru6 commented Feb 16, 2024

I'm reporting the following situation I encountered when I tried to include images in my gt table for reporting. I reported this issue in blastula issue page too.

Prework

Description

I would like to send an email with a gt table inside, this gt table should have a column of images. The problem is that the images that go on to the table aren't properly formatted.

Reproducible example

library(gt);library(Microsoft365R);library(blastula)

# From: https://gt.rstudio.com/reference/local_image.html
 
dplyr::tibble(
  pixels = px(seq(10, 35, 5)),
  image = seq(10, 35, 5)
) |>
  gt() |>
  tab_header(
    title = "A1",
    subtitle = "A2"
  ) |> 
  text_transform(
    locations = cells_body(columns = image),
    fn = function(x) {
      local_image(
        filename = test_image(type = "png"),
        height = as.numeric(x)
      )
    }
  ) |> 
  as_raw_html() -> prueba

correo_gnrl <- get_business_outlook()
mail_temp <- compose_email(md(prueba))
correo_gnrl$create_email(mail_temp,
                         to = "blablabla@sth.com",
                         send_now = TRUE)

Expected result

(The images increase in size)

image

What I got

(All of the same size)

image

Session info

> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=Spanish_Peru.utf8  LC_CTYPE=Spanish_Peru.utf8    LC_MONETARY=Spanish_Peru.utf8
[4] LC_NUMERIC=C                  LC_TIME=Spanish_Peru.utf8    

time zone: America/Lima
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] blastula_0.3.4      Microsoft365R_2.4.0 gt_0.10.1          

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5       httr_1.4.7        cli_3.6.2         rlang_1.1.2       stringi_1.8.3     generics_0.1.3   
 [7] jsonlite_1.8.8    glue_1.6.2        juicyjuice_0.1.0  V8_4.4.1          htmltools_0.5.7   sass_0.4.8       
[13] fansi_1.0.6       rappdirs_0.3.3    tibble_3.2.1      base64enc_0.1-3   fastmap_1.1.1     lifecycle_1.0.4  
[19] stringr_1.5.1     compiler_4.3.2    AzureGraph_1.3.4  dplyr_1.1.4       fs_1.6.3          AzureAuth_1.3.3  
[25] Rcpp_1.0.11       pkgconfig_2.0.3   rstudioapi_0.15.0 digest_0.6.33     R6_2.5.1          tidyselect_1.2.0 
[31] utf8_1.2.4        curl_5.2.0        pillar_1.9.0      commonmark_1.9.0  magrittr_2.0.3    tools_4.3.2      
[37] withr_3.0.0       mime_0.12         xml2_1.3.6 

@Amaru6 Amaru6 changed the title Format Images inside Rows Format Images inside Cells Feb 18, 2024
@Amaru6 Amaru6 changed the title Format Images inside Cells Format Images inside Cells email output Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants