Tag Archives: html to image

How to use proxy with Html2Image Liux:

Sometimes you may want to use html2image in an enviroment that needs to set proxy.

One of our customers shares his tip on this problem. here it is:

  • Configure the proxy options into ./html2image/greprefs/all.js.

Example below, this is the standard firefox proxy setting

pref(“network.proxy.autoconfig_url”,        “http://myProxy/myScript”);
pref(“network.proxy.type”,                  2);

If you have any comments on this solution, let us know!


How to capture html to image on x64 windows

X64 windows is becoming more and more polular platform. Htmlsnapshot component has supported html to image on windows x64 platform along with the industry trend.

There are mainly four x64 windows: XP x64,  Vista X64, Windows 2003 x64, Windows 2008 X64.  The first two are client platform while the last two are server version.

To convert html to image on windows x64 platform, there are two ways:

1. Convert html to image with the 32 bit component. To do this, html to image function must run under a 32 bit process. By default, htmlsnapshot will register itself as 32 bit component on Windows X64/

For example, you can run the simple vbscript demo with 32 bit mode like this:

c:WindowsSysWOW64cscript.exe DemoVBScriptsimple.vbs

2. Convert html to image with native 64bit mode. Since IE has been ported to x64, so htmlsnapshot can capture html to image with 64 bit IE.  To do this, first you need to manual register the 64 bit htmlsnapshot. In the installation folder, run below command:

regsvr32 x64htmlsnap2.dll

Now, you can run the simple vbscript demo with 64bit mode like this:

c:Windowssystem32cscript.exe DemoVBScriptsimple.vbs

Another thing to notice is that in order to capture html page with flash to image, you has to use the 32 bit mode. The reason is that the flash player doesn’t have 64 bit version yet.  Adobe is still working on this. Please read:


How to run html2image linux on Ubuntu64

Here is detailed example on how to use html2image linux on Ubuntu 64 bit (Ubuntu 7.10 – the Gutsy Gibbon)

This serves as a good example on how to use html2image. Other 64 bit Linux distribution can be done similarly.

1. Install Ubuntu 64

2. Login into the server (you can use the text mode login here. This is suitable for headless server as well)

If you are in GUI mode, Ctrl+Alt+F2 will switch you to text mode.

3. Enter a folder, download html2image

wget http://www.guangmingsoft.net/htmlsnapshot/html2image.i386.tar.gz

4. Extract html2image

tar xvzf html2image.i386.tar.gz
cd html2image

4. Install 32bit application support libraries.

sudo apt-get install ia32-libs

5. Install Xvfb coming with the Ubuntu

sudo apt-get install xvfb

6. Run Xvfb

Xvfb :1 -screen 0 640x480x24 -nolisten tcp -audit 4 -auth X1.cfg & export DISPLAY=:1
Of course, you could try high resolution like 1024x768x24

7. Now you can run html2image, it should work
./html2image www.google.com a.jpg

Check if the a.jpg is created successfully.


convert html to image with htmlsnapshot in php

Here are a more complete examples of using htmlsnapshot to convert html to image with php on Windows.

Note the following things:

1. You copy/paste the below code into test.php and run on command line

   php.exe test.php

 2. Yon can see it uses GetErrorCode to handle errors to make your code more robust.


$url = “http://google.com/“;
$path = “.\”;
$img = “1.jpg”;
$timg = “1s.jpg”;
$limg = “1b.jpg”;
$iimg = “1i.jpg”;

$com = new COM(“HTMLSNAP2.HtmlSnap.1″);
$com->SnapUrl($url, $path.$img );

$err = $com->GetErrorCode();
if ($err == 1)

$com->SetClipRect(0, 0, 1024, 768);

$com->GetThumbnailImage($path.$img, $path.$timg, 160, 120, 0);
$com->GetThumbnailImage($path.$img, $path.$limg, 320, 240, 0);

print “Snapshot of “.$url.”. Click to enlarge<br>”;
print “<a href=”.$iimg.” mce_href=”.$iimg.”><img src=”.$timg.” mce_src=”.$timg.”><img src=”.$limg.” mce_src=”.$limg.”></a><br/>”;
    print “error happens”;

A handy script to convert html to image

You may need to run a command line utility to convert html or url to image. Here is a handy script that converts url/html to image with our award winning htmlsnapshot product.

Save the below code into a script snapurl.vbs (Or you can find this script in htmlsnapshotdemovbscript)

set args = WScript.Arguments
num = args.Count

if num <> 2 then
   WScript.Echo “Usage: [CScript | WScript] snapurl.Vbs Url ImageFile”
   WScript.Quit 1
end if

‘demo how to convert html to image
Dim snap

‘Create the Html Snapshot Object
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetCode “Input your license code here to remove watermark”
snap.SnapUrl args.Item(0), args.Item(1)
WScript.echo “Snap return:” & CStr(snap.GetErrorCode)

‘Free object
Set snap = Nothing

 After that, you can run on command line like below:

cscript.exe snapUrl.vbs www.google.com g.jpg
cscript.exe snapUrl.vbs file://c:1.html g.jpg

50 good wordpress plugin list

Manage WordPress Comments

  • Subscribe To Comments – Allows readers to recieve notifications of new comments that are posted to an entry.
  • WP AJAX Edit Comments – Allows users and admins to edit comments on a post inline using AJAX.
  • Get Recent Comments – displays excerpts of the most recent comments and/or trackbacks that have been posted to the articles in your blog.
  • Close Old Posts – Closes comments on old posts without any DB queries.
  • WP Grins – allows you to put clickable smilies on your post and comments forms.
  • WordPress Paged Comments – allows comment paging. Useful for those very popular blog entries receiving many comments.
  • Live Comment Preview – the simplest way to get live comment previews on your site.
  • Show Top Commentators – Encourage more discussion from your readers, by displaying their names and number of comments they have made recently to your sidebar.
  • WordPress Gravatar Plugin – outputs the gravatar based on the commenters email address.
  • MyAvatars – shows MyBlogLog’s avatars in your comments
  • Comment Relish – Sends a thank you e-mail to your first time commentators.
  • Favatars – displays the favicon associated with the commenter’s website.
  • Brian’s Threaded Comments – adds a ‘Reply to this comment’ link to every comment. Makes it easy for people to reply to comments and discuss better.
  • Dofollow – lets you remove the nofollow attribute from your comments.
  • OpenID Comments for WordPress – allows users to leave comments using their OpenID.
  • Extended Comment Options – allows you to switch comments and/or pings on or off for batches of existing posts.

Stop WordPress Spam

  • Akismet – intelligently blocks spam comments. Checks your comments against the Akismet web service to see if they are spam or not.
  • Spam Karma 2 (SK2) – is an anti-spam plugin for the WordPress meant to stop all forms of automated Blog spam effortlessly, while remaining as unobtrusive as possible to regular commenters.
  • Bad Behavior – is a set of PHP scripts which prevents spambots from accessing your site by analyzing their actual HTTP requests and comparing them to profiles from known spambots.
  • Math comment spam protection – Adds a math question to comments form to detect human input and block automated spambots.
  • WP-Contact Form with Spam Protection – creates a contact form on your blog, through which your readers can contact you easily.

Expert WordPress SEO

  • Google XML Sitemaps Generator – creates a sitemap of all articles on your WordPress blog. Helps Google and other search engines index every article you write.
  • Permalink Redirect – replies a 301 permanent redirect, if requested URI is different from entry’s (or archive’s) permalink. It is used to ensure that there is only one URL associated with each blog entry.
  • All in One SEO Pack – Optimizes your WordPress blog for Search Engines (Search Engine Optimization).
  • Head META Description – Insert HTML META description tags using post excerpts.
  • SEO Title Tag – Optimize your wordpress title tags for search engines. Mass edit the title tags of posts, pages, category pages, tag pages etc.
  • Enforce www. Preference – will help preserve your permalinks by enforcing your no-www or yes-www preference and will strip off index.php from the ends of URIs.
  • Optimal Title – allows you to have your blog name tacked on to the end of the page title instead of having it appear first.
  • Quick META Keywords – will automatically add META Keywords tags to every single post based on categories under which the article is categorized.

Easy WordPress Navigation

  • Related Posts – Returns a list of the related entries based on active/passive keyword matches. Increase pageviews by providing targeted related content.
  • WP-PageNavi – Adds a more advanced page navigation to WordPress, which is very useful for navigation on index and category pages.
  • Evermore – Abbreviate all posts when viewed on multiple post pages. Helpful to create expandable posts summaries in WordPress. Combine with Less that changes the (more…) link so it displays the entire post, not just the part after the “more”.
  • Random Redirect – Allows you to create a link to a random post on your blog. Lets readers browse in a StumbleUpon-like fashion.
  • Lightbox JS Plugin – used to overlay images on the current page into neat Javascript-powered overlay popups.
  • WordPress Mobile Edition – shows an interface designed for a mobile device when visitors come to your site on a mobile device.
  • Popularity Contest – keeps a count of your post, category and archive views, comments, trackbacks, etc. and uses them to determine which of your posts are most popular.
  • Extended Live Archive – implements a dynamic, AJAXified way of digging into the archives of a blog.
  • Landing Sites – When visitors is referred to your site from a search engine, it shows them related posts to their search on your blog.
  • Clean Archives – designed to display your archive listings in a clean and uniform fashion. It lists the Month / Year, the day of the month the article was published, the title of the article, and the number of comments that have been made on each article.
  • Custom Query String – set the number of posts (custom queries) for every single page on your website like categories, archives, or search results pages.
  • Feed List – very useful for adding other RSS feeds to your site.
  • Sidebar Widgets because it allows you to move things (widgets) around, in and out of your sidebar. Not required for WordPress 2.2 and above.
  • KB Advanced RSS Widget – a wordpress widget that gives you complete control over how RSS feeds are parsed for your sidebar.
  • Category Cloud Widget – Adds a sidebar widget to display the categories as a tag cloud.
  • Adhesive – lets you make the posts “sticky”, such that the posts will remain at the top of the page.
  • Permalinks Migration Plugin – safely change your permalink structure without breaking the old links to your website or affecting your search engine rankings.

Interactive WordPress Posts

  • Share This – lets your visitors to add your post to various social bookmarking sites, or send a link via e-mail to a friend.
  • Digg this – detects incoming links from Digg.com to your wordpress post and automatically display a link back to the digg post, for people to digg your story.
  • Delicious Cached++ – uses the built-in MagpieRSS engine functions to create a list of the latest bookmarks on a del.icio.us account, from its RSS feed, keeping the feed cached in the database.
  • WP-Notable – displays a series of icons below each post allowing your readers to easily submit you to many different social bookmarking and networking sites.
  • WP-Email – Allows people to recommend/send your WordPress blog’s post/page to a friend.
  • WP-PostRatings – Adds an AJAX rating system for your WordPress blog’s post/page.
  • EasyTube – allows you to easily embed YouTube and Google Videos using one simple tag.
  • Twitter Updater – automatically sends a Twitter status update to your Twitter account when you create, publish, or edit your WordPress post. More best Twitter plugins.

WordPress Admin Management Tools

  • WordPress Database Backup – On-demand backup of your WordPress database. Back up your blog today.
  • WP-cache – Very fast cache module. Survive a Digg traffic spike easily.
  • WP-Supercache – A modification of WP-Cache that produces static html files.
  • Batch Categories – Easily manage the mass categorization of posts that match various criteria. Power edit your categories.
  • podPress – adds lots of features designed to make WordPress the ideal platform for hosting a podcast.
  • TinyMCE Advanced – adds 16 plugins to TinyMCE, the WordPress wysiwyg editor. Adds over 40 new buttons to the toolbar, which is now two rows plus one hidden row.
  • Exec-PHP – allows php tags inside the content or excerpt of your posts and pages to be executed just as in usual PHP files.
  • WordPress Reporter – allows you to easily view your Google Analytics and Feedburner reports in your WordPress administration area.
  • WordPress.com Stats – Tracks views, post/page views, referrers, and clicks. Requires a WordPress.com API key.
  • WP Tiger Administration – Uses power of CSS2 to manipulate the functionality of the WordPress administration area
  • Admin Drop Down Menu – eliminates the need for this double clicking on the Admin screens by allowing you to see the second level menu just by placing your mouse over a main menu.
  • InstantUpgrade – provides is a easy and safe way to upgrade your WordPress automatically with a single click.
  • Maintenance Mode Plugin – Adds a splash page to your blog that lets visitors know your blog is down for maintenance. Logged in administrators get full access to the blog including the front-end.
  • Theme Test Drive – allows you to safely test drive any theme on your blog as an administrator, while visitors continue to see the default one.

Advertising on WordPress

  • Ad Rotator – Rotates Ads randomly from a specified text file.
  • AdSense-Deluxe – is a WordPress plugin offering advanced options for managing the automatic insertion of Google AdSense or Yahoo Publisher Network (YPN) ads to your WordPress posts. More Google Adsense WP plugins.
  • Buy Me a Beer – allows your readers to donate money to you via PayPal on pretext of buying a beer.
  • WordPress BankRoll – offers to help you cut out the middleman by allowing advertisers to buy reviews directly on your blog.

WordPress Blog Translation

Enhance WordPress RSS Feeds

  • Feedburner Feedsmith – Forwards all feed traffic to Feedburner while creating a randomized feed for Feedburner to pull from.
  • Simple Feed Copyright – adds a simple copyright notice to full text wordpress feeds.
  • Full Text Feed – Prevents WordPress 2.1+ from adding a more link to your website’s feed. Ensures you get full text feeds.
  • Add Related Posts to Your Feed – adds a list of Related Posts to your full text feed. Requires either UTW or Related Posts plugin installed and activated.
  • RSS Signature – allow the addition of a custom tagline, signature or copyright message to the wordpress generated rss feeds.

Random WordPress Stuff

  • Democracy – adds AJAX polling functionality to your WordPress blog.
  • flickrRSS – allows you to easily display Flickr photos on your weblog

Convert html to multipage tiff file

 Htmlsnapshot now supports converting html into multiple page tiff files. here is the sample code. You just need to specify the page width in pixel. The component will save the image into a multipage tif.

‘demo html to multipage tiff generation function

Set WshShell = WScript.CreateObject(“WScript.Shell”)
‘Declare object
Dim snap
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetTimeOut CLng(200000)
snap.SnapUrl “http://www.google.com/“, “google.tiff”

‘Set CCITT3 encoding for TIFF
snap.SetTIFFEncoder 1
snap.SaveMultipageTiff “m-google-ccitt-3.tiff”, 200

‘Set CCITT4 encoding for TIFF
snap.SetTIFFEncoder 2
snap.SaveMultipageTiff “m-google-ccitt-4.tiff”, 200

‘Set RLE encoding for TIFF
snap.SetTIFFEncoder 3
snap.SaveMultipageTiff “m-google-rle.tiff”, 200

‘Set none encoding for TIFF
snap.SetTIFFEncoder 4
snap.SaveMultipageTiff “m-google-none.tiff”, 200

snap.SetTIFFEncoder 1

‘Change thresholding when converting to monochrome
snap.SetThreshold 200
snap.SaveMultipageTiff “m-google-ccitt-4-1.tiff”, 200

Set snap = Nothing