yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.38k stars 873 forks source link

render multiple resolutions for bitmap engines #1354

Closed maxheld83 closed 6 years ago

maxheld83 commented 7 years ago

It appears to me that upstream uses of knitr, especially when they are outputting to HTML such as bookdown (this issue) and blogdown(this issue might require several resolution versions of bitmap assets, for example to support responsive images (say, download a different filesize depending on the viewport).

I think this is not presently possible, hope I am not wrong. Unfortunately, I am a little bit confused of how or where (in knitr?) this could be implemented, but I hope it's at least a worthwhile thought.

Perhaps, knitr could learn to accept a vector of resolutions for dpi, and then upstream functions such as blogdown or bookdown could supply reasonable default sets of DPIs, to which knitr could render?

Ps.: There is also a more limited use case for this when non-R raster images are included via include_graphics(). When the bitmap is large, we might want quite different resolutions for a PDF output, and an HTML output, where load times matter more. This would require re-sizing in R as per this issue, and is probably a really niche use case.

yihui commented 6 years ago

As mentioned in https://github.com/rstudio/bookdown/issues/316, I don't think I'll ever have the time to implement this and personally I don't have much interest in it, so I'd say you have to do it by yourself if you really want it. The knitr hook system is fairly open. Thanks for the suggestion, though.

github-actions[bot] commented 3 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.