-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Some web services allow us to retrieve images of substances. There are already implementations in PR #235 and PR #247. Also ChemSpider and PubChem both offer such functionality. I thought it would be good to open a small discussion about design considerations to ensure consistency.
- function name alternatives:
*_view(),*_viewer(),_*img(),*_image(). Let's choose one and stick to it. I prefer*_img(), as proposed by @andschar, e.g.actor_img(),pc_img(). - arguments:
query,from,format,width,height,verbose, in this order? - outputs: 1. a list of raw character vectors. 2. exported images. Alternatively, we can add two more arguments, one to decide if we want to download, e.g.
output = c('image', 'download')as suggested by @gjgetzinger, and another forpath.
On first thought, I think I would prefer these functions to return a list of raw character vectors. I tried png, svg, jpeg, these can all be accessed e.g. through httr::content(httr::GET(url), type = "image"). Raw vectors can then be rendered easily with image processing packages like magick, e.g. plot(as.raster(image_read(raw))) and also exported in any format, but we wouldn't have to import them as dependencies, so webchem could remain lightweight.
What do you think?