<commit_before>// Load in modules
var system = require('system'),
    fs = require('fs'),
    webpage = require('webpage'),
    _  = require('./nimble.min.js');

// Grab the arguments
var args = system.args,
    encodedFilesStr = args[1];

// If there is no image, throw an error
if (!encodedFilesStr) {
  throw new Error('No images specified to grab stats from.');
}

// Parse the image paths
var imgsStr = decodeURIComponent(encodedFilesStr),
    imgs = JSON.parse(imgsStr);

// In parallel
_.map(imgs, function getStats (img, cb) {
  // Load in the image
  // DEV: If this fails, use data/html
  var page = webpage.create();
  page.open(img, function (status) {
    // Pluck out the image dimensions
    var dimensions = page.evaluate(function () {
      // Grab the image
      var img = document.getElementsByTagName('img')[0];

      // Get the dimensions of the image
      var style = window.getComputedStyle(img),
          dimensions = {
            width: style.width,
            height: style.height
          };
      return dimensions;
    });

    // Adjust the dimensions off of `px`
    dimensions.height = +(dimensions.height.replace('px', ''));
    dimensions.width = +(dimensions.width.replace('px', ''));

    // Callback with the dimensions
    cb(null, dimensions);
  });
}, function handleStats (err, dimensionArr) {
  // Stringify and emit the dimensions
  var retStr = JSON.stringify(dimensionArr);
  console.log(retStr);

  // Leave the program
  phantom.exit();
});

<commit_msg>Updated phantom stats and now Windows + phantomjs is running but timing out on big ticket<commit_after>// Load in modules
var system = require('system'),
    fs = require('fs'),
    webpage = require('webpage'),
    _  = require('./nimble.min.js');

// Grab the arguments
var args = system.args,
    filepath = args[1],
    encodedFilesStr = fs.read(filepath);

// If there is no image, throw an error
if (!encodedFilesStr) {
  throw new Error('No images specified to grab stats from.');
}

// Parse the image paths
var imgsStr = decodeURIComponent(encodedFilesStr),
    imgs = JSON.parse(imgsStr);

// In parallel
_.map(imgs, function getStats (img, cb) {
  // Load in the image
  // DEV: If this fails, use data/html
  var page = webpage.create();
  page.open(img, function (status) {
    // Pluck out the image dimensions
    var dimensions = page.evaluate(function () {
      // Grab the image
      var img = document.getElementsByTagName('img')[0];

      // Get the dimensions of the image
      var style = window.getComputedStyle(img),
          dimensions = {
            width: style.width,
            height: style.height
          };
      return dimensions;
    });

    // Adjust the dimensions off of `px`
    dimensions.height = +(dimensions.height.replace('px', ''));
    dimensions.width = +(dimensions.width.replace('px', ''));

    // Callback with the dimensions
    cb(null, dimensions);
  });
}, function handleStats (err, dimensionArr) {
  // Stringify and emit the dimensions
  var retStr = JSON.stringify(dimensionArr);
  console.log(retStr);

  // Leave the program
  phantom.exit();
});


{'fraction_non_alphanumeric': 0.13115802943058222, 'fraction_numerical': 0.0012795905310300703, 'mean_word_length': 2.8893034825870645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2622201', 'n_tokens_mistral': 925, 'n_tokens_neox': 911, 'n_words': 284}