<commit_before>// Load in our dependencies
var assert = require('assert');
var concat = require('concat-stream');

// Define our canvas constructor
function Canvas(width, height, gmsmith) {
  // Ignore width/height
  // DEV: Our canvas dimensions are dynamically defined by x/y of each image
  var canvas = gmsmith.gm(1, 1, 'transparent');

  // Override the -size options (won't work otherwise)
  canvas._in = ['-background', 'transparent'];

  // Save the canvas
  this.canvas = canvas;
}
// Define mapping for extensions to gm counterpart
Canvas.defaultExtension = 'png';
Canvas.supportedFormats = ['png', 'jpeg'];
Canvas.prototype = {
  addImage: function addImage (img, x, y, cb) {
    // Add the image
    var canvas = this.canvas;

    // TODO: Pull request this in to gm
    canvas.out('-page');
    canvas.out('+' + x + '+' + y);
    canvas.out(img.file);
  },
  'export': function exportFn (options, cb) {
    // Flatten the image (with transparency)
    var canvas = this.canvas;
    canvas.mosaic();

    // Extract our extension
    var format = options.format || Canvas.defaultExtension;
    assert(Canvas.supportedFormats.indexOf(format) !== -1,
      '`gmsmith` doesn\'t support exporting a "' + format + '". Please export either a `png` or `jpeg`');

    // Update the quality of the canvas (if specified)
    var quality = options.quality;
    if (quality !== undefined) {
      canvas.quality(quality);
    }

    // Export our data via a stream
    // https://github.com/aheckmann/gm/blob/1.21.1/lib/command.js#L116-L144<commit_msg>Cleaned up extension vs format confusion<commit_after>// Load in our dependencies
var assert = require('assert');
var concat = require('concat-stream');

// Define our canvas constructor
function Canvas(width, height, gmsmith) {
  // Ignore width/height
  // DEV: Our canvas dimensions are dynamically defined by x/y of each image
  var canvas = gmsmith.gm(1, 1, 'transparent');

  // Override the -size options (won't work otherwise)
  canvas._in = ['-background', 'transparent'];

  // Save the canvas
  this.canvas = canvas;
}
Canvas.defaultFormat = 'png';
Canvas.supportedFormats = ['png', 'jpeg'];
Canvas.prototype = {
  addImage: function addImage (img, x, y, cb) {
    // Add the image
    var canvas = this.canvas;

    // TODO: Pull request this in to gm
    canvas.out('-page');
    canvas.out('+' + x + '+' + y);
    canvas.out(img.file);
  },
  'export': function exportFn (options, cb) {
    // Flatten the image (with transparency)
    var canvas = this.canvas;
    canvas.mosaic();

    // Validate our format
    var format = options.format || Canvas.defaultFormat;
    assert(Canvas.supportedFormats.indexOf(format) !== -1,
      '`gmsmith` doesn\'t support exporting a "' + format + '". Please export either a `png` or `jpeg`');

    // Update the quality of the canvas (if specified)
    var quality = options.quality;
    if (quality !== undefined) {
      canvas.quality(quality);
    }

    // Export our data via a stream
    // https://github.com/aheckmann/gm/blob/1.21.1/lib/command.js#L116-L144
{'fraction_non_alphanumeric': 0.14127604166666666, 'fraction_numerical': 0.008463541666666666, 'mean_word_length': 3.152702702702703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '599316', 'n_tokens_mistral': 965, 'n_tokens_neox': 923, 'n_words': 295}