tweak allows you to quickly modify an image, so it can be used for a pictogram, an infographic, an animation...
library(tweak)
img <- system.file("img", "Rlogo.png", package="png") img2 <- tweak::tweak(img,"grey",bold=1) showcase(img2) class(img2)
img <- system.file("img", "Rlogo.png", package="png") imgs <- list( tweak(img), # original tweak(img,alpha=0.5), # transparent tweak(img,resize=0.7), # resized tweak(img,"black"), # greyscales tweak(img,"darkred"), # any R color tweak(img,"darkblue"), # tweak(img,"darkgreen"), # tweak(img,"gold"), # tweak(img,cut=c(0.7,0)), # clean cut tweak(img,cut=c(0.7,0), # cut with cut_effects=list(alpha=0.5)), # transparency cut_effects=list(alpha=0.5)), # transparency tweak(img,cut=c(0.7,0), # cut with cut_effects=list(color="darkgreen"), # color on both color="darkred"), # sides tweak(img,cut=c(0.2,0.2), # horiz cut up & down cut_effects=list(alpha=0.5,color="darkorange"), # with transparancy color="darkred",cut_dir = "h"), # and colors tweak(img,"darkred",col_mix=0.3), # mix original with color tweak(img,"darkred",bold = 1), # make completely bold tweak(img,"darkred",bold = 0.5), # make bolder tweak(img,"darkred",alpha=0.3,bold = 0.5) # mix bold and transparency ) showcase(imgs)
Let's now run the same code with a pic from online
I can use it directly:
img <- "http://www.officialpsds.com/images/thumbs/Money-Bag-psd75301.png" img2 <- tweak::tweak(img,"darkorange") showcase(img2)
Or if I want to use it several times:
tempf <- tempfile() download.file(img,tempf,mode = "wb") img <- tempf imgs <- list( tweak(img), # original tweak(img,alpha=0.5), # transparent tweak(img,resize=0.7), # resized tweak(img,"black"), # greyscales tweak(img,"darkred"), # any R color tweak(img,"darkblue"), # tweak(img,"darkgreen"), # tweak(img,"gold"), # tweak(img,cut=c(0.7,0)), # clean cut tweak(img,cut=c(0.7,0), # cut with cut_effects=list(alpha=0.5)), # transparency tweak(img,cut=c(0.7,0), # cut with cut_effects=list(color="darkgreen"), # color on both color="darkred"), # sides tweak(img,cut=c(0.2,0.2), # horiz cut up & down cut_effects=list(alpha=0.5,color="darkorange"), # with transparancy color="darkred",cut_dir = "h"), # and colors tweak(img,"darkred",col_mix=0.3), # mix original with color tweak(img,"darkred",bold = 1), # make completely bold tweak(img,"darkred",bold = 0.5), # make bolder tweak(img,"darkred",alpha=0.3,bold = 0.5) # mix bold and transparency ) showcase(imgs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.