2
2
# '
3
3
# ' This is a helper function to plot preview assets
4
4
# ' (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.
6
6
# '
7
7
# ' @param url image URL to be plotted.
8
8
# '
12
12
preview_plot <- function (url ) {
13
13
preview_check(url )
14
14
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 = " " )
16
16
grid :: grid.raster(img )
17
17
}
18
18
@@ -39,6 +39,12 @@ preview_check <- function(url) {
39
39
" This function requires `jpeg` package. Please, use" ,
40
40
" install.packages('jpeg')."
41
41
))
42
+ ,
43
+ jpg = if (! requireNamespace(" jpeg" , quietly = TRUE ))
44
+ .error(paste(
45
+ " This function requires `jpeg` package. Please, use" ,
46
+ " install.packages('jpeg')."
47
+ ))
42
48
)
43
49
}
44
50
@@ -55,7 +61,8 @@ preview_read_file <- function(url) {
55
61
preview_switch(
56
62
url ,
57
63
png = png :: readPNG(temp_file ),
58
- jpeg = jpeg :: readJPEG(temp_file )
64
+ jpeg = jpeg :: readJPEG(temp_file ),
65
+ jpg = jpeg :: readJPEG(temp_file )
59
66
)
60
67
}
61
68
0 commit comments