Code Monkey home page Code Monkey logo

imageclipr's Introduction

imageclipr

CRAN version

RStudio Addin: Copy images from clipboard into RMarkdown .Rmd files.

Usage of imageclipr

Installation

devtools::install_github('Timag/imageclipr')

Dependencies

R packages library(rstudioapi), (library(rmarkdown) for markdown files)

For linux xclip is required. For debian, ubuntu,... install it with:

sudo apt-get install xclip 

Open issues

  • can not:

-- copy and paste image and text together

-- copy and paste an image by copying the file in the explorer

Technical walkthrough

(highlevel): https://stackoverflow.com/questions/55541345/copy-and-paste-an-image-from-clipboard-to-rmarkdown-rmd-code

Usage

Select the addin

Note: You will see "Paste Img to Rmd file" instead of "Insert Image".

Addin selection

Adding a keyboard shortcut (Recommended)

In RStudio go to Tools - Modify Keyboard Shortcuts...

Note: You will see "Paste Img to Rmd file" instead of "Insert Image".

Find Shortcuts

Modify Shortcuts

(This project is part of my life long application to RStudio :))

imageclipr's People

Contributors

buedenbender avatar toniiiio avatar wwolf avatar xiaoa6435 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

imageclipr's Issues

Organize images into subdirectory by default

STR:

  1. Use this addin to paste multiple images
  2. Check the location image files

Result: images files are at the same directory with the rmd file
Expectation: it seems untidy when a lot of images are pasted. They should be put into the /img/ subdirectory, or an option can be offered in the shinyr configuration interface.

Image does not show up

Thanks for making this package!

I was able to follow all instructions, but once the code is pasted into R the image does now show up. Any ideas?

Clipboard data is not an image

Hi!

I am on Debian 11. The same bug appears on XFCE and Cinnamon Desktop Environment. I installed the extension following the instructions, including installing the xclip package in linux. However, when I execute the paste image addin command, I get the following error message:

Error in save_clipboard_image(img_file_name, dir = dirname(file_path)) : Clipboard data is not an image.

I have looked around and I am suspecting the native clipboard to somehow interfere with xclip ability to handle the image once I copy it to the clipboard.

Maxime

Changes to the `imageclipr::config` are not permanent

After either selecting from the addin menu or calling the function imageclipr::config() in the viewer the shiny
applet opens to change the configuration.
However the changes seem not to persist.

E.g., I just changed the Plot title to (New . and pressed done (screenshot below)

However when I tried it out it still displayed the default Plot title. from the old config. Which also checks with when I open the config applet as well.
imageclipr issue config

I run R Version 4.2.1 on Windows.

Shortcut key

Thanks for the package!

I recently installed this and the shortcut key is no longer "InsertImage" but rather "Paste Img to Rmd file". Could you change this in the README?

image

As the package also appears differently in the Addin tab, so might want to change the image for that as well in the README.

image

Error in (function () : Please save the file before pasting an image.

Hi,

Thanks for the great idea.

My understanding was that you don't need to save the image but can only have it in the clipboard but I get the following error:

Error in (function () : Please save the file before pasting an image.

image

Basically I installed the packages, assigned a keyboard shortcut to the InsertImage Addin, copied a photo from a web browser, and tried to paste it in an Rmarkdown file.

I'd appreciate any help.

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils    
[5] datasets  methods   base     

other attached packages:
[1] magrittr_1.5

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3           RSpectra_0.16-0     
 [3] plyr_1.8.6           compiler_3.6.3      
 [5] pillar_1.4.3         BiocManager_1.30.10 
 [7] RColorBrewer_1.1-2   tools_3.6.3         
 [9] digest_0.6.25        packrat_0.5.0       
[11] evaluate_0.14        lifecycle_0.2.0     
[13] tibble_2.1.3         gtable_0.3.0        
[15] lattice_0.20-40      pkgconfig_2.0.3     
[17] rlang_0.4.5          Matrix_1.2-18       
[19] igraph_1.2.4.2       rstudioapi_0.11     
[21] microbenchmark_1.4-7 yaml_2.2.1          
[23] parallel_3.6.3       xfun_0.12           
[25] gridExtra_2.3        stringr_1.4.0       
[27] dplyr_0.8.5          knitr_1.28          
[29] vctrs_0.2.4          grid_3.6.3          
[31] tidyselect_1.0.0     data.table_1.12.8   
[33] glue_1.3.1           ellipse_0.4.1       
[35] R6_2.4.1             rARPACK_0.11-0      
[37] rmarkdown_2.1        reshape2_1.4.3      
[39] ggplot2_3.3.0        purrr_0.3.3         
[41] tidyr_1.0.2          corpcor_1.6.9       
[43] scales_1.1.0         mixOmics_6.10.8     
[45] nipals_0.7           htmltools_0.4.0     
[47] matrixStats_0.55.0   MASS_7.3-51.5       
[49] assertthat_0.2.1     colorspace_1.4-1    
[51] stringi_1.4.6        munsell_0.5.0       
[53] crayon_1.3.4     

No image at path clipboardImage1.png

Hi,

I think this is a great idea, was really excited to find that it exists. However, it doesn't seem to work for me. Perhaps I have installed it incorrectly.

I used:
packages.install('devtools')
devtools::install_github('Timag/imageclipr')

This didn't work at all - threw an error message complaining that PIL wasn't installed. So from Terminal I ran 'sudo pip install pillow'.

Now when I run 'devtools::install_github('Timag/imageclipr')' it installs without error but when I try to paste something in I get this error:
image

MacBook Pro 2018 running OS X Mojave 10.14.6
RStudio 1.1.456
I have Python installed, I think, on this machine but I have never used it. This may be the issue - I have no idea whether it's working, whether all the paths are correct etc.

Any suggestions?

Error : (converted from warning) unable to re-encode 'insertImageCode.R' line 26

Hello, I've tried devtools::install_github('Timag/imageclipr') and got this error:

Error : (converted from warning) unable to re-encode 'insertImageCode.R' line 26

I've analyzed the line
write (the clipboard as «class PNGf») to theFile

It seems the «» is the culpable. I forked and removed them, and it installed fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.