An open API service indexing awesome lists of open source software.

https://github.com/bgreenwell/imgflipr

An R Wrapper to the Official Imgflip API
https://github.com/bgreenwell/imgflipr

Last synced: about 2 months ago
JSON representation

An R Wrapper to the Official Imgflip API

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# imgflipr

The goal of imgflipr is to, you guessed it, interact with the official [Imgflip API](https://api.imgflip.com/) through R. For making custom memes, check out the R `r emo::ji("package")` [meme](https://github.com/GuangchuangYu/meme/).

## Installation

Currently, you can only install this package from GitHub:

```{r, eval=FALSE}
devtools::install_github("bgreenwell/imgflipr")
```

## Example

Grab a tibble of the most popular memes:

```{r example}
memes <- imgflipr::get_memes()
memes
```

Grab the ID for a particular image:

```{r memes}
batman <- memes[memes$name == "Batman Slapping Robin", "id"]
```

Caption this image (note, I have my [Imgflip](https://imgflip.com/) username and password stored as an environment variable in my `.Renviron` file):

```{r caption-image}
url <- imgflipr::caption_image(
template_id = batman,
username = Sys.getenv("IMGFLIP_USERNAME"),
password = Sys.getenv("IMGFLIP_PASSWORD"),
text0 = "When should I use pie charts?",
text1 = "Never!"
)
url
```

For now, just visit the link to your captioned image, it's that easy! Alternatively, you can include the captioned image in R markdown by passing the resulting URL to `knitr::include_graphics()`:

```{r view-image, out.width="50%", fig.align="center"}
knitr::include_graphics(url)
```