data-raw/sticker.R

library(hexSticker)
library(here)

#imgurl_src <- "https://kth-library.github.io/assets/img/logo.png"

# the kth-logo-cirle is generated by this command 
# (requires imagemagick ie sudo apt install imagemagick-6.q16)
# convert -size 1186x1186 xc:none -fill kth-logo.png -draw "translate 593,593 circle 0,0 593,0" kth-logo-circle.png

imgurl_src <- file.path(here(), "data-raw", "assets", "kth-logo-circle.png")
imgurl_dest <- file.path(here(), "data-raw", "assets", "kth-sticker.png")

sticker(filename = imgurl_dest, 
  # KTH Blue
  h_fill = "#1954a6", 
  h_color = RColorBrewer::brewer.pal(7, "Greys")[5],
  subplot = imgurl_src, package = "bibliomatrix", 
  p_size = 20, s_x = 1, s_y = .75, s_width = .6
)

# dest location inspired by https://stackoverflow.com/questions/44113759
image_read(imgurl_dest) %>%
  image_resize("120x120") %>%
  image_write(file.path(here(), "man", "figures", "sticker.png"))
KTH-Library/bibliomatrix documentation built on Feb. 29, 2024, 5:54 a.m.