http://phantomJs.org offers a free tool for locally capturing HTML from a file (if you include it using the command line option and use file:// URI) or from a website and attribute it to the image. This is a very well-established very popular tool. It is also used by people who write automated tests. There is a wiki page that covers this tool and similar ones.
It has a crop option. You can run the output of this using other image processing tools to scale it.
As for getting smart previews / thumbnails like Twitter and Facebook, I'm not sure. I know that there is a popular oEmbed protocol that is available on Twitter and other sites, as well as ways to extract metadata, with which you could create your own small HTML file and then display it on the image.
(Note about phantomJs: If you donβt get the required image quality in the image, try increasing the quality setting for the image parameter to 100, and by increasing the page zoom factor, a zoom factor of 2 gives significantly better quality than a zoom factor of 1 - see the API docs for scaling )
clearlight Mar 27 '17 at 15:00 2017-03-27 15:00
source share