<commit_before>"use strict";

const ImageData   = require("./ImageData");
const gm = require("gm").subClass({ imageMagick: true });

const cropSpec = /(\d+)x(\d+)([+-]\d+)?([+-]\d+)?(%)?/;

class ImageResizer {

    /**
     * Image Resizer
     * resize image with ImageMagick
     *
     * @constructor
     * @param Number width
     */
    constructor(options) {
        this.options = options;
    }

    /**
     * Execute resize
     *
     * @public
     * @param ImageData image
     * @return Promise
     */
    exec(image) {
      var sys = require('sys')

      var exec = require('child_process').exec;

      function puts(error, stdout, stderr) { sys.puts(stdout) }

      exec("convert --version", puts);

        console.log('Resize image: ' + image.fileName);
        console.log('Resize image size: ' + image.data.length);
        var toType = function(obj) {
            return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
        };
        console.log('image data type: ' + toType(image.data));
        const acl = this.options.acl;

        return new Promise((resolve, reject) => {
            var img = gm(new Buffer(image.data))
	              .geometry(this.options.size.toString())
                      .toBuffer(function (err, buffer) {
                         console.log('buffer: ' + buffer.length);
                         if (err) 
                           reject(err);
			 resolve(new ImageData(
						 image.fileName,
						 image.bucketName,
						 buffer,
						 image.headers,
						 acl<commit_msg>remove image resizing to test whether buffer breaks on resize<commit_after>"use strict";

const ImageData   = require("./ImageData");
const gm = require("gm").subClass({ imageMagick: true });

const cropSpec = /(\d+)x(\d+)([+-]\d+)?([+-]\d+)?(%)?/;

class ImageResizer {

    /**
     * Image Resizer
     * resize image with ImageMagick
     *
     * @constructor
     * @param Number width
     */
    constructor(options) {
        this.options = options;
    }

    /**
     * Execute resize
     *
     * @public
     * @param ImageData image
     * @return Promise
     */
    exec(image) {
      var sys = require('sys')

      var exec = require('child_process').exec;

      function puts(error, stdout, stderr) { sys.puts(stdout) }

      exec("convert --version", puts);

        console.log('Resize image: ' + image.fileName);
        console.log('Resize image size: ' + image.data.length);
        var toType = function(obj) {
            return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
        };
        console.log('image data type: ' + toType(image.data));
        const acl = this.options.acl;

        return new Promise((resolve, reject) => {
            var img = gm(new Buffer(image.data))
	              //.geometry(this.options.size.toString())
                      .toBuffer(function (err, buffer) {
                         console.log('buffer: ' + buffer.length);
                         if (err) 
                           reject(err);
			 resolve(new ImageData(
						 image.fileName,
						 image.bucketName,
						 buffer,
						 image.headers,
						 acl
{'fraction_non_alphanumeric': 0.15248897290485192, 'fraction_numerical': 0.000630119722747322, 'mean_word_length': 1.8916211293260474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4292249', 'n_tokens_mistral': 1005, 'n_tokens_neox': 915, 'n_words': 196}