Get any Link - Thumbnail (like facebook does)

I'd like to find a code that returns a link thumbnail (image)
just like facebook does..
Preferably .Net code.
… I suppose that the algorithm should:
First look at the html "og:image" meta tag.
and if it doesn't exist - return the first available image in the html. like: xpath = "//img"
Thanks, Aryeh.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phantom JS
Use PhantomJS to create screenshots. PhantomJS comes with an example called rasterize.js, which does exactly this. Example:
phantomjs rasterize.js ms.png

Open in new window

Selenium Client Driver for C#
Taking screenshots with Selenium WebDriver ( Sampel code:
The code to take a screenshot is not complex:
using OpenQA.Selenium.IE;
using OpenQA.Selenium;
using System.Drawing.Imaging;
public void TakeScreenshot(IWebDriver driver, string saveLocation)
    ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;
    Screenshot screenshot = screenshotDriver.GetScreenshot();
    screenshot.SaveAsFile(saveLocation, ImageFormat.Png);

IWebDriver driver = new InternetExplorerDriver();
TakeScreenshot(driver, @"C:\temp\ms.png");

Open in new window

Use a web service
Here is a list of some services:

Create your own service
You can use a headless browser to accomplish this. WebKit is a good candidate (the underlying engine for PhantomJS, Chrome)
tuchfeldAuthor Commented:
but as understand: these are page snapshots (which in fact I already know how to do, using System.Windows.Forms.WebBrowser.DrawToBitmap).
Do they support "og:image" meta tag
as FIRST SUGGESTION for the page Thumbnail?
Ooops... I downplayed the Open Graph Image issue. You can pass the URL to the OpenGraph-Net libray (GitHub or Nuget) which will parse your HTML and extract the Open Graph metadata and put it into a nice object for you.
OpenGraph graph = OpenGraph.ParseUrl("");
if(graph.Image!=null) {
     Uri imgUrl = graph.Image;
     //download the image and do as you please

Open in new window

Sidenote: System.Windows.Forms.WebBrowser.DrawToBitmap is based on the IE based web browser control. IE... well... even Microsoft have thrown in the towel :) It's slow and because it's not standards compliant, there are lots of cases where sites appear distorted in IE. But anyway, if it works well for you, why change it! Lool
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

tuchfeldAuthor Commented:
OK, Thanks for the valuable info..
Now back to the case when we do NOT have an image meta tag.
Are the solutions you suggested above return the FIRST AVAILABLE IMAGE (as facebook does)
or a snapshot of the page?
take as an example this link:
Which should return:
(and not a snapshot of the page..).
Without the og:image metadata, I don't really see  how you will know? Does one just parse the HTML and take the first image? The biggest image by dimensions? I'm not sure on this one
tuchfeldAuthor Commented:
I can let the user decide which image to choose...
and get the images by scanning: WebBrowser.Document.All
(should do it AFTER webBrowser.ReadyState = WebBrowserReadyState.Complete).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tuchfeldAuthor Commented:
Eventually, I didn't find an automatic answer but I let the user to choose.
My Thanks to MlandaT for assisting me to get to this conclusion.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.