var WebPage = require('webpage');
var System = require('system');
address = System.args[1];
var index = 0;

var screenshots = [
  {"dimensions" : [975,500],
  "filename": './screenshots/screenshot_l.png'},
  {"dimensions" : [720,400],
  "filename": './screenshots/screenshot_m.png'},
  {"dimensions" : [400,200],
  "filename": './screenshots/screenshot_s.png'}
];

var capturescreen = function(dimensions, filename){
  var page = WebPage.create();
  page.viewportSize = {
    width: dimensions[0],
    height: dimensions[1]
  };
  page.open(address);
  page.onLoadFinished = setTimeout(function() {
      page.render(filename);
      page.close();
      index++;
      // Give it a second before calling next. 
      // Phantom runs into some sort of race condition without this
      setTimeout(nextPage, 1000); 
  }, 3000);
}

var nextPage = function(){
  if(!screenshots[index]){
    phantom.exit();
  }
  capturescreen(screenshots[index].dimensions, screenshots[index].filename);
}

nextPage();
@@ -25,21 +25,21 @@
 ebpage')
-;%0Avar
+,%0A   
  System 
@@ -57,18 +57,22 @@
 system')
-;%0A
+,%0A    
 address 
@@ -91,13 +91,13 @@
 s%5B1%5D
-;%0Avar
+,%0A   
  ind
@@ -105,16 +105,125 @@
 x = 0;%0A%0A
+// All the sizes to screenshot. %0A// Note: PhantomJs uses the heights specified here as a min-height criteria%0A
 var scre
@@ -259,11 +259,11 @@
  %5B97
-5,5
+0,3
 00%5D,
@@ -335,17 +335,17 @@
  : %5B720,
-4
+3
 00%5D,%0A  %22
@@ -769,16 +769,17 @@
 ndex++;%0A
+%0A
       //

Add height is not absoulte note