title: Saving interactive graphs through viewer (export) as (PNG)
body: <p>I want to save my interactive graph as a png, i can do it through viewer and export it as png but i've thousands of them and must take them automatically.</p>
  
  <p>There's a way which is using <code>webshot</code> package, but i tried this approach and it takes alot of time, because i want to save them at the same time, for example : i've 4000 html graphs generated using R and must save them as image in time interval 1 min, when i use <code>webshot</code>, it takes arround 43 mins because <code>system2</code>takes alot of time .</p>
  
  <p>so <strong>i want to export them using function which viewer pane use</strong>, here's an image explain what i want . </p>
  
  <p><a href="https://i.stack.imgur.com/ytCtf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ytCtf.png" alt="enter image description here"></a></p>
  
  <p>Here's code as an example for interactive graph, that doesn't mean my graphs r leaflet class, i provide it as an example.</p>
  
  <pre><code>library(leaflet)
  
  m &lt;- leaflet() %&gt;%
    addTiles() %&gt;%  # Add default OpenStreetMap map tiles
    addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
  </code></pre>
  
  <p>and here's what i'm thinking of :</p>
  
  <pre><code>function(m,"SaveAs.png")
  </code></pre>
  
  <p>Please i need help, i searched a lot and spent a lot of time trying to find a solution.</p>
  
  <hr>
  
  <p>according to this question 
  <a href="https://stackoverflow.com/questions/31336898/how-to-save-leaflet-in-r-map-as-png-or-jpg-file">How to save Leaflet in R map as png or jpg file?</a></p>
  
  <p>It differs from my question , i need generic function for any interactive graphs , there's functions for <code>plotly</code> but it's only for plotly graphs,Also the question usion webshot function which using PhantomJs and i mentioned above that PhantomJS is tooooo slow also Selenium also wkhtmltoimage, i tried lots of things.  </p>
  
  <p>Please notice that i need generic function or at least the function that <strong>viewer</strong> is using</p>