-
-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggestion: offer rescaling / compression option to include_graphics()
for external images
#1273
Comments
If anybody is able to implement it, I'll be happy to take a look at the pull request, otherwise I'm afraid I won't have the time to implement it in the near future. |
Just two more thoughts on this in light of related On the one hand (automatic) rescaling/resizing/cropping is on the roadmap for HUGO anyway. That'll probably be easier and/or more specialised than it could be in R. For On the other hand, it's not available yet, and the HUGO support wouldn't fix this for other knitr use cases. |
I have now implemented this for my own purposes (inside
This is a bit clumsy, but it works. This both increases the compression, and downscales the image. While this works, it's pretty darn slow (at least on OS X for some reason, Travis CI was much faster ...), and I'm guessing this is because R isn't really meant/optimised for this kind of thing. @yihui is this a direction you think might be worthwhile for me to pursue in a pull request? I'm a bit confused as to where in the (Updated to now feature |
include_graphics()
for external imagesinclude_graphics()
for external images
I suggest you write your own wrapper function like include_image = function(x, ...) {
# first process x by yourself
magic::whatever....
# return
knitr::include_graphics(x, ...)
} I don't have much interest in provide built-in support for this. |
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. |
it would be really nice if
knitr::include_graphics()
(which is used heavily, and elegantly inbookdown()
would allow me to specify a DPI and size, and then rescale the external image accordingly, as per this stack-exchange question.Note: I mean external image, like some JPEG from a camera or something, not plot images generated by R.
It would be neat especially for any kind of website output, if
knitr
(or some other element of the toolchain) could take care of the resizing, so that users don't end up deploying huge images when bookdown is rendered to a website, etc.(I guess, in principal, the same concern applies to PDFs, though file size is usually less of a concern there).
The text was updated successfully, but these errors were encountered: