Dear Colleagues, We are attempting to create trees using R with our Ruby on Rails application. However, we are running into a problem involving the creation of the graphic. We would like them to be in either jpg or png format so that users can save, but due to a lack of control over our sever we are unable to start X11 server. Is there a way to create these images without using X11 server? Thanks, JIllian -- 917-434-7511 http://www.jilliankozyra.com
library(GDD) Or install Xvfb on your server ________________________________________ From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Jillian E Kozyra [jillyh0 at gmail.com] Sent: 13 March 2010 16:27 To: r-help at r-project.org Subject: [R] Creating images without X11 Dear Colleagues, We are attempting to create trees using R with our Ruby on Rails application. However, we are running into a problem involving the creation of the graphic. We would like them to be in either jpg or png format so that users can save, but due to a lack of control over our sever we are unable to start X11 server. Is there a way to create these images without using X11 server? Thanks, JIllian -- 917-434-7511 http://www.jilliankozyra.com ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 13-Mar-10 16:27:05, Jillian E Kozyra wrote:> Dear Colleagues, > > We are attempting to create trees using R with our Ruby on Rails > application. However, we are running into a problem involving the > creation of the graphic. We would like them to be in either jpg or png > format so that users can save, but due to a lack of control over our > sever we are unable to start X11 server. Is there a way to create > these images without using X11 server? > > Thanks, > JIllian > -- > 917-434-7511 > http://www.jilliankozyra.comProvided you trust your code to produce correctly the graphic you want (i.e. you do not need to inspect the graphic on-screen to verify that it is correct), then there should be no problem. As a test, I just switched (Ctrl-Alt-F1) to a text console in Linux, and then executed R --no-save png("MyPNG.png") plot(rnorm(10),rnorm(10)) dev.off() Then I killed R, switched back (Ctrl-Alt-F7) to the graphical desktop, and then found the file MyPNG.png safe and well which, when displayed, was just what it should be. Summary: So long as you do not try to plot graphics to screen, and use the png() or jpg() device (as above), then the graphic will be written to file without needing X11. However, you will not, of course, be able to see them on screen. If you just did the plot() command without encapsulating it in a device to write files as above, then nothing would happen. It is possible to convert a graphics file into "ASCII Art", and then you could see a (very) coarse approximation to your graphic on-screen in a console terminal. However, I'm not going to make any recommendations on how to do that! Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 13-Mar-10 Time: 22:16:16 ------------------------------ XFMail ------------------------------
On Sat, Mar 13, 2010 at 4:27 PM, Jillian E Kozyra <jillyh0 at gmail.com> wrote:> Dear Colleagues, > > We are attempting to create trees using R with our Ruby on Rails > application. However, we are running into a problem involving the > creation of the graphic. We would like them to be in either jpg or png > format so that users can save, but due to a lack of control over our > sever we are unable to start X11 server. Is there a way to create > these images without using X11 server? >Not sure what version of R you are using, but the png() device hasn't needed an X11 server since way back when. Watch: $ export -n DISPLAY $ R > png() > plot(1:10) > dev.off() > q() then I have a very fine Rplot001.png file. Now it may be that you can't compile PNG support without X11 being there at compile time, but if you can compile R on a workstation with X11 support then that R should work find on your server to produce pngs even without X11 support there and then. jpeg() device works the same - X11 not needed at runtime. What makes you think it's lack of X11 that is making png or jpeg devices fail? Run the capabilities() function and see if your R has png and jpeg support - my suspicion is that you've compiled it on the server with no X11 headers. It doesn't need a server at runtime. Barry
Jillian E Kozyra wrote:> > Dear Colleagues, > > We are attempting to create trees using R with our Ruby on Rails > application. However, we are running into a problem involving the > creation of the graphic. We would like them to be in either jpg or png > format so that users can save, but due to a lack of control over our > sever we are unable to start X11 server. Is there a way to create > these images without using X11 server? > > Thanks, > JIllian > >I had this exact same problem last summer when attempting to set up an automated process involving image generation on a remote server. Since I didn't have admin rights to the server, I ended up switching to the Cairo package for image generation as it uses the Cairo library rather than X11 as the back end. The other solution involved setting some sort of obscure, arcane X11 permission that I can't recall right now. All I can recall is that finding it was a frustrating half-day of Google searching and digging through man pages. I would suggest Cairo. Hope this helps! -Charlie ----- Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://n4.nabble.com/Creating-images-without-X11-tp1592016p1592201.html Sent from the R help mailing list archive at Nabble.com.