-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
[FR] Make it easier for users to shrink image sizes #614
Comments
That's a good idea. I used to manually optimize images. I'll look into tinieR. Thanks! |
For pure shrinking of the size for optimization (like tinieR if I understand correctly), I believe For resizing there is also, I think we could make one version based on magick package. (and that is what |
Simply shrinking an image to the desired dimension (i.e. resizing) is easy. Optimizing image losslessly is hard. I just did some quick testing and https://tinypng.com seems to be quite decent in reducing the file size of both PNG and JPG images. |
…d use it: rstudio/blogdown#614) the tinieR package is a more comprehensive implementation of the Tinify API but I only need one feature (i.e. shrink) and the package has several additional dependencies (fs, glue, httr, png, jpeg, rprojroot, yaml)
Yihui Xie (23): make the title shorter, otherwise it could be wrapped by `R CMD build` and 'Yihui Xie' will be marked as "mis-spelled" by `R CMD check` clarify a news item add a function news2md() to convert package news to Markdown rstudio/tinytex@4772b5e add a category argument to news2md() so that category names could be discarded don't generate the bullet list if all items are empty BDR suggest authors not use ftp:// sites fix #52: default to using renv::install() to install packages when pkg_install() is called inside an renv project forgot to suggest renv address BDR's request to not use ftp:// (it is still supported, but at some point we may have to only support uploading via https://win-builder.r-project.org/upload.aspx) default lib = NULL for renv::install() (#52) add helper functions stop2() and warning2(), which uses call. = FALSE add a function format_bytes() borrowed from tinytex:::auto_size() and built on top of format.object_size() add a function tinify() to compress images (e.g., blogdown users could use it: rstudio/blogdown#614) escape % move a few functions rename src to pkg in install_dir(), and factor out the code to build the tarball to pkg_build() xfun::upload_win_builder() can be called without arguments now use [[ to get the file instead of list(file); delete the package tarball if it is automatically built a lightweight version of submit_cran() ignore readme to avoid CRAN's URL checking fix #51: don't add backticks to math environments when \begin{} and \end{} do not match CRAN release v0.23
The development version of xfun has a function remotes::install_github('yihui/xfun') If you call it with the argument |
Martin Mächler (1): specify the default library location since base_pkgs() can "hang" Yihui Xie (11): start the next version roxygenize and bump version forgot to pass ... to dir.create() in dir_create() close #68: add support for more file extensions bump version factor out a function all_files() that changes list.files()'s default argument values make it possible to return all logo paths close rstudio/blogdown#614: add a function shrink_images() to shrink (and optionally compress) images under a directory also support .webp images svg images can fail on GHA's Linux machines CRAN release v0.32
# CHANGES IN xfun VERSION 0.35 - Added a new argument `token` to `protect_math()` to optionally include a token around math expressions. - `base64_uri()` relies less on the **mime** package now. For some common file extensions (e.g., `.jpg`/`.png`), this function knows their MIME types. - `stringsAsStrings()` has been removed from this package. # CHANGES IN xfun VERSION 0.34 - Added a new function `alnum_id()` to generate ID strings from a character vector. - The function `stringsAsStrings()` has been deprecated. # CHANGES IN xfun VERSION 0.33 - Reverted the change for #68: the characters `-+!_#` are no longer accepted by default in filename extensions, since they are relatively rare and caused a breakage in rstudio/bookdown#1369. If you wish to allow for these characters, you may use the new `extra` argument in `file_ext()` and related functions, e.g., `xfun::file_ext(x, extra = '-+!_#')`. - The function `stringsAsStrings()` will be deprecated in a future release of **xfun**, because the global option `stringsAsFactors = FALSE` has become the default in base R since 4.0.0. # CHANGES IN xfun VERSION 0.32 - Added a function `shrink_images()` to shrink images to a maximum width using the **magick** package (thanks, @apreshill, rstudio/blogdown#614). - Added a function `tinify_dir()` as a wrapper of `tinify()` to compress images under a directory. - `file_ext()` supports more file extensions now, such as `.c++`, `.FB2K-COMPONENT`, and so on (thanks, @tentacles-from-outer-space, #68). - Fixed the issue that `xfun::base_pkgs()` could hang R (thanks, @mmaechler, #66). - The `...` argument in `dir_create()` was not passed to `dir.create()`.
I would love a function way to do this, built into blogdown, since I struggle with this all the time!
I also have been looking at: https://jmablog.github.io/tinieR/
Also I know this is important: https://bookdown.org/yihui/rmarkdown-cookbook/optipng.html
It would be cool to offer a way to do this based on regex, like all resize & optimize all images in
content/*thumbnail*
😉Similar to:
hugodown::use_tidy_thumbnail()
The text was updated successfully, but these errors were encountered: