-
Notifications
You must be signed in to change notification settings - Fork 5
/
hexsticker.R
executable file
·54 lines (41 loc) · 1.37 KB
/
hexsticker.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env Rscript
library(hexSticker)
library(here)
library(magick)
# hexsticker
imgurl_src <-
"https://biodiversitydata.se/wp-content/uploads/2021/02/sbdi-logo-orginal-large.png" %>%
image_read() %>%
image_resize("400x400")
imgurl_src %>% image_write(path = "logo-400.png")
imgurl_src <- "logo-400.png"
imgurl_dest <- file.path(here(), "sbdi.png")
sticker(
filename = imgurl_dest,
h_fill = "#e0e2e5",
h_color = RColorBrewer::brewer.pal(7, "Greys")[5],
subplot = imgurl_src, s_x = 1, s_y = 1, s_width = 0.9,
package = "", p_color = "#3e7131",
# 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(imgurl_dest)
# login screen logo
imgurl_src %>%
image_read() %>%
image_resize("240x240") %>%
image_write(path = "logo.png")
imgurl_src %>%
image_read() %>%
image_resize("237x237") %>%
image_write(path = "logo-large.png")
# the logo-cirle is generated by this command
# (requires imagemagick ie sudo apt install imagemagick-6.q16)
# convert -size 1186x1186 xc:none -fill logo.png -draw "translate 593,593 circle 0,0 593,0" logo-circle.png
cmd <- sprintf(
'convert -size 1186x1186 xc:none -fill %s -draw "translate 593,593 circle 0,0 593,0" %s',
"logo-large.png", "logo-circle.png"
)
system(cmd)