Open file in browser from command?

I'm wondering if there's a way to open a file (in posit.cloud) that's in a project folder into a browser tab? In particular I'm hoping to automatically open up an animated gif at the end of a script. I saw a helpful post that showed how to do this with magick, but it's remarkably slow.

image_browse(image_read("aimation.gif"),  browser =   getOption("browser"))

It seems like there must be a better way to quickly launch this without having to process the file within R? One possibility might be to be able to know what the specific url prefix is that's produced when you open up a file from the files pane. Any other ideas?

Thanks!

Hi AldenGriffith!

Give this a try:

library(rstudioapi)

viewer("/cloud/project/path/to/image.jpg")

Cheers,
Mike

Perfect! Thanks so much

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.