Downloaded pictures with download.file - function are fragmented


as stated in the title all the pictures i download with the download.file - function are heavily fragmented.

For reference the code i am using:

am <- read.xlsx(file.choose())

am$id <- str_extract(am$id, "\\d+")
am <- am[!$id), ]
# am[apply(am, 1, function(x) sum(>=9, ]

foreach(i = 1:nrow(am)) %do% {
  urls <- str_split(am$image_url[i], "/")
                destfile = paste0(path3,quiet=T,  str_extract_all(urls, "\\d+")[[1]][1], ".jpg"))

Even if I only use the download.file-function for one picture it comes out fragmented.

And here how the picture look like vs how they should: (Imgur Link)

Doe anyone know the solution to my problem?

Thanks in advance and i'm more than happy to provide further information if needed

Interesting, I didn't know about that: you apparently need to specify that you want to save the file as binary (on Windows), by setting the mode:

download.file("", "test.jpg", mode="wb")
1 Like

it worked, thank you very much :smiley:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.