Skip to content

Instantly share code, notes, and snippets.

@matt-dray
Created September 27, 2023 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-dray/ce541a10d0c56dc0d34dfcd48237bfac to your computer and use it in GitHub Desktop.
Save matt-dray/ce541a10d0c56dc0d34dfcd48237bfac to your computer and use it in GitHub Desktop.
Deep-fried Sarcastic Spongebob on nontrivial package submission
# Regarding this toot: https://fosstodon.org/@coolbutuseless/111134523140682110
# Referring to this guidance: https://cran.r-project.org/web/packages/policies.html
# Using this deep-fry tech: https://www.rostrum.blog/posts/2021-11-07-deepfry/
library(magick)
library(spongebob)
fry <- function(
img_path, emoji_path,
text_top, text_bottom,
depth = c("shallow", "deep")) {
depth <- match.arg(depth)
cat("Heating oil... ")
emoji <- magick::image_read(emoji_path)
emoji_where <- sample(c(
paste0("north", c("east", "west")),
paste0("south", c("east", "west")),
"east", "west" # e.g. 'east' is right
), 1)
img <- image_read(img_path) |>
image_annotate(
text_top, "north", size = 80, font = "Impact",
color = "white", strokecolor = "black"
) |>
image_annotate(
text_bottom, "south", size = 80, font = "Impact",
color = "white", strokecolor = "black"
) |>
image_scale("1000") |>
image_composite(emoji, gravity = emoji_where) |>
image_colorize(30, "orange") |> # tint
image_modulate(brightness = 80, saturation = 120, hue = 90) |>
image_contrast(sharpen = 100) |>
image_noise()
cat("dunking meme... ")
if (depth == "shallow") {
img <- img %>% image_implode(-0.5) # bulge
compress <- 8
} else if (depth == "deep") {
img <- img %>% image_implode(-1) # more bulge
compress <- 1 # maximum compression
}
path_out <- tempfile("meme", fileext = ".jpeg")
image_write(img, path_out, "jpeg", compress)
cat("crisp.")
image_read(path_out)
}
sponge_path <- paste0( # URL to meme image
"https://raw.githubusercontent.com/matt-dray/rostrum-blog/",
"master/static/post/2021-11-07-deepfry_files/spongebob.jpg"
)
emoji_path <- paste0( # URL to cry/laugh emoji
"https://raw.githubusercontent.com/matt-dray/rostrum-blog/",
"master/static/post/2021-11-07-deepfry_files/deepfry-emoji.jpg"
)
top_txt <- tospongebob("CRAN hosts packages of\npublication quality")
bot_txt <- tospongebob("A package’s contribution\nhas to be non-trivial")
fry(sponge_path, emoji_path, top_txt, bot_txt)
@matt-dray
Copy link
Author

spongebob-trivialpants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment