File tree 1 file changed +0
-26
lines changed
1 file changed +0
-26
lines changed Original file line number Diff line number Diff line change 2
2
# ' @export
3
3
magrittr :: `%>%`
4
4
5
- read_path <- function (path ){
6
- image <- if (is.character(path )){
7
- if (is_url(path )){
8
- read_url(path )
9
- } else {
10
- read_file(path )
11
- }
12
- } else if (is.raw(path )){
13
- path
14
- } else {
15
- stop(" Parameter 'image' must be an image object, file path or raw vector with image data" )
16
- }
17
- return (image )
18
- }
19
-
20
5
is_url <- function (path ){
21
6
grepl(" ^https?://" , path )
22
7
}
@@ -59,17 +44,6 @@ download_url <- function(url){
59
44
return (filename )
60
45
}
61
46
62
- read_url <- function (path ){
63
- req <- curl :: curl_fetch_memory(path )
64
- if (req $ status_code > = 400 )
65
- stop(sprintf(" Failed to download %s (HTTP %d)" , path , req $ status ))
66
- return (req $ content )
67
- }
68
-
69
- read_file <- function (path ){
70
- readBin(normalizePath(path , mustWork = TRUE ), raw(), file.info(path )$ size )
71
- }
72
-
73
47
assert_image <- function (image ){
74
48
if (! inherits(image , " magick-image" ))
75
49
stop(" The 'image' argument is not a magick image object." , call. = FALSE )
You can’t perform that action at this time.
0 commit comments