22# '
33# ' This is a helper function to plot preview assets
44# ' (e.g. quicklook, thumbnail, rendered_preview).
5- # ' Currently, only png and jpeg formats are supported.
5+ # ' Currently, only png, jpeg and jpg formats are supported.
66# '
77# ' @param url image URL to be plotted.
88# '
1212preview_plot <- function (url ) {
1313 preview_check(url )
1414 img <- preview_read_file(url )
15- plot(1 : 10 , ty = " n" , axes = F , xlab = " " , ylab = " " )
15+ plot(1 : 10 , type = " n" , axes = FALSE , xlab = " " , ylab = " " )
1616 grid :: grid.raster(img )
1717}
1818
@@ -39,6 +39,12 @@ preview_check <- function(url) {
3939 " This function requires `jpeg` package. Please, use" ,
4040 " install.packages('jpeg')."
4141 ))
42+ ,
43+ jpg = if (! requireNamespace(" jpeg" , quietly = TRUE ))
44+ .error(paste(
45+ " This function requires `jpeg` package. Please, use" ,
46+ " install.packages('jpeg')."
47+ ))
4248 )
4349}
4450
@@ -55,7 +61,8 @@ preview_read_file <- function(url) {
5561 preview_switch(
5662 url ,
5763 png = png :: readPNG(temp_file ),
58- jpeg = jpeg :: readJPEG(temp_file )
64+ jpeg = jpeg :: readJPEG(temp_file ),
65+ jpg = jpeg :: readJPEG(temp_file )
5966 )
6067}
6168
0 commit comments