I was just wondering how to take a screenshot of my webpage. Lets say i have an interface around all borders, and in the middle is the frame that shows websites. How would it be possible to take a screenshot of that frame. I would not need any borders and interface included in that snap. Only the frame, how can it be accomplished?
I have included the picture which represents the layout of a website, so no need to include the entire layout but just this segment in the frame. How to capture that frame in an image programmatically? What tools and programming language can do this for me?
PhantomJS is a fully programmable headless browser. It is able to produce PNG, JPEG, GIF and PDF files from the web pages it opens.
Use document.querySelector(), then element.getBoundingClientRect() DOM APIs to get the rectangle containing the element you want to rasterize, then set webpage.clipRect property to it and call webpage.render() method to produce the image. See this answer for an example.
I do not know if you really have no limitations on the technology you wish to use, but phantomJS (headless browser) can certainly be use here. Example: How to render part of a page with PhantomJS
Related
I am using Codename One.
In my program I generate html code dynamically. I would like to grab a screenshot of the web browser view so I can send the screenshot as an image to users.
I've tried calling browserComponent.paint(Graphics) to draw this onto a mutable image but this resulted in a blank image. Is there a way to do this?
You can't grab a screenshot of a peer component.
HTML is rendered natively in the OS as a PeerComponent see this blog post explaining peer components. Unfortunately peer components are rendered separately so you can't grab a screenshot of a peer.
You can draw anything you want onto an Image using mutable images but you can't grab the image of an arbitrary peer. Check out our graphics section in the developer guide to see how one draws on an image.
I am using Fancybox for displaying photo galleries on my web sites.
I am also quite happy with it but as I have to extend it a bit (e.g. show a hyperlink in the caption below the image), I thought it is worth to look around what other gallery frameworks are around.
I am looking for non-flash galleries, non-PHP: JAVA ONLY and jQuery based solutions.
Thanks for your input. I will collect all your feedbacks and update this question text.
ON the client side I recommend the JQuery plugin LightBox.
You can create a gallery from multiple images, and they are all nicely framed in a popup.
I have a project requirement to render HTML and capture the rendered image as a file on a headless CentOS 5.4 server. My specific requirements are:
1) Input will be a URL to the page to render (or file:// URL to a local HTML file), output will be an image file containing the rendered image of the page
2) CSS must be supported by the renderer up to CSS level-1
3) Static images in the page must be displayed properly in the rendered image, including any transparent color in .GIF or .PNG files
4) Must be able to run on a headless CentOS 5.4 server.
5) Solution must not depend on any product or component that is not free for commercial use
I do not need to do anything with the page other than get the screen capture and save it to an image. The hard part seems to be doing this in a headless environment. Some of the solutions that I've seen discussed need a display in order to work.
Any suggestions?
Thanks in advance,
Jim
SOLUTION:
I ended up using the Standard Widget Toolkit library (www.eclipse.org/swt) for its embedded browser capabilities. This allowed me to programmatically open a window with a browser control in it, render the page, then capture the content of the window to an image file (usually a PNG). The only downside to this approach that cannot be avoided is a "flicker" when the window must be made visible for a moment in order to do the screen capture. I can live with it. The rest was just code to initialize the SWT objects that obtain system resources, a listener to check for a successful completion of the page load, and some code to clean up a hung connection (when the page load never completes for whatever reason).
I got a teammate to play around with xvfb (X virtual framebuffer) on CentOS Linux. The initial tests appear to work, so it looks like the advice from the poster below (who said to try xvfb) may be a viable solution for the headless server part of my issue.
You can start a virtual X-windows environment using xvfb . You can now start a regular browser to render the page and use a screencapture utility to capture the content of the window. It is not pretty, but straghtforward to do.
WebKit is open-source and embeddable, maybe you can use this in a small native app to render on a canvas and save it to disk?
Is it possible to take a screen shot (using the Print Screen) and paste it from the System Clipboard directly into a web pages text area field (which I would create)? Do I need a browser plug-in? Can Flash do this?
**The solution only has to work in Internet Explorer.
This is not possible without a plugin.
It's not possible in Flash or Silverlight either, although it is possible in AIR.
I think you will have to write a custom ActiveX Control in order to do this. The control should automatically take a screenshot and send captured image to server-side code..
There is one more option - create a java applet, which will do the job, and also will help you to avoid cross browser issue.
I want to devlop simple image application in java. I need to display the image without anything around it. That is, there should be absolutely no application frame or title bar or anything else. When I open the image in this application, all I will see is the image floating on my screen.
In should when my application shold work like google picasa(desktop version).
When i install picasa and double clikc on image it shows me the full scrin image without any application window.
Or you could set the frame to be undecorated.
frame.setUndecorated(true);
It will look and behave just as a Window container.
Use java.awt.Window or javax.swing.JWindow?
It doesn't sound like you need a window at all. A SplashScreen should do what you want, provided that you don't need the user to interact with the image in any way other than viewing it. You can look at the SplashDemo.java file from the link above to get started.