<commit_before>'use strict';

/* Services */


// Demonstrate how to register services
// In this case it is a simple value service.
angular.module('myApp.services', []).
  service('imageTools', ['$q', '$timeout', function($q, $timeout) {
    var ImageTools = function() {};

    ImageTools.prototype.imageP = function(url) {
      var d = $q.defer(),
          image = new Image();

      image.onload = function() { d.resolve(image); };
      image.src = url;

      return d.promise;
    };

    ImageTools.prototype.resizeURLP = function(image, newSize) {
      var d = $q.defer(),
          self = this;

      $timeout(function() {
        var pixelArray = self.pixelArray(image);

        d.resolve(self.pixelArrayToURL(pixelArray));
      });

      return d.promise;
    };

    ImageTools.prototype.pixelArray = function(image) {
      var canvas = document.createElement('canvas'),
          ctx = canvas.getContext('2d'),
          width = image.width,
          height = image.height;

      canvas.width = width;
      canvas.height = height;

      ctx.drawImage(image, 0, 0, width, height);
<commit_msg>Use canvas image resizing idgaf<commit_after>'use strict';

/* Services */


// Demonstrate how to register services
// In this case it is a simple value service.
angular.module('myApp.services', []).
  service('imageTools', ['$q', '$timeout', function($q, $timeout) {
    var ImageTools = function() {};

    ImageTools.prototype.imageP = function(url) {
      var d = $q.defer(),
          image = new Image();

      image.onload = function() { d.resolve(image); };
      image.src = url;

      return d.promise;
    };

    ImageTools.prototype.resizeURLP = function(image, newSize) {
      var d = $q.defer(),
          self = this;

      $timeout(function() {
        var canvas = document.createElement('canvas'),
            ctx = canvas.getContext('2d');

        canvas.width = newSize.width;
        canvas.height = newSize.height;

        ctx.drawImage(image, 0, 0, newSize.width, newSize.height);

        d.resolve(canvas.toDataURL());
      });

      return d.promise;
    };

    ImageTools.prototype.pixelArray = function(image) {
      var canvas = document.createElement('canvas'),
          ctx = canvas.getContext('2d'),
          width = image.width,
          height = image.height;

      canvas.width = width;
      canvas.height = height;

      ctx.drawImage(image, 0, 0, width, height);

{'fraction_non_alphanumeric': 0.14479081214109926, 'fraction_numerical': 0.0036915504511894994, 'mean_word_length': 2.469416785206259, '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': '186794', 'n_tokens_mistral': 734, 'n_tokens_neox': 704, 'n_words': 167}