<commit_before>var config = require('config');
var uuid = require("uuid/v4");
var join = require('path').join;
var fs = require('fs-extra');
// e.g. /_image_cache/{uuid}.jpg will be final URL
var cache_folder_name = '_image_cache';
var fs = require('fs-extra');
var resize = require('./resize');
var minify = require('./minify');
var extname = require('path').extname;
var uuid = require('uuid/v4');
var join = require('path').join;
var debug = require('debug')('entry:build:plugins:image');

module.exports = function (blogID) {

  return function (path, _callback) {

    var name = uuid() + extname(path);
    var finalPath = join(config.blog_static_files_dir, blogID, cache_folder_name, name);
    var src = '/' + cache_folder_name + '/' + name;

    // Wrap callback to clean up file if we encounter an error in this module
    // When transformer creates and cleans up a tmp file for us, can remove this.
    var callback = function (err, info) {
      
      if (!err) return _callback(null, info);

      fs.remove(finalPath, function(){
      
        _callback(err, info);
      });
    };

    debug('Copying', path, 'to', finalPath);
    fs.copy(path, finalPath, function(err){

      if (err) return callback(err);
      
      debug('Resizing', finalPath);
      resize(finalPath, function(err, info){

        if (err) return callback(err);

        if (!info.width || !info.height) return callback(new Error('No width or height'));
        
        debug('Minifying', finalPath);
        minify(finalPath, function(err){

          if (err) return callback(err);

          info.src = src;

          callback(null, info);
        });
      });
    });  
  };
};<commit_msg>Disabled minify<commit_after>var config = require('config');
var uuid = require("uuid/v4");
var join = require('path').join;
var fs = require('fs-extra');
// e.g. /_image_cache/{uuid}.jpg will be final URL
var cache_folder_name = '_image_cache';
var fs = require('fs-extra');
var resize = require('./resize');
var minify = require('./minify');
var extname = require('path').extname;
var uuid = require('uuid/v4');
var join = require('path').join;
var debug = require('debug')('entry:build:plugins:image');

module.exports = function (blogID) {

  return function (path, _callback) {

    var name = uuid() + extname(path);
    var finalPath = join(config.blog_static_files_dir, blogID, cache_folder_name, name);
    var src = '/' + cache_folder_name + '/' + name;

    // Wrap callback to clean up file if we encounter an error in this module
    // When transformer creates and cleans up a tmp file for us, can remove this.
    var callback = function (err, info) {
      
      if (!err) return _callback(null, info);

      fs.remove(finalPath, function(){
      
        _callback(err, info);
      });
    };

    debug('Copying', path, 'to', finalPath);
    fs.copy(path, finalPath, function(err){

      if (err) return callback(err);
      
      debug('Resizing', finalPath);
      resize(finalPath, function(err, info){

        if (err) return callback(err);

        if (!info.width || !info.height) return callback(new Error('No width or height'));
        
        debug('Minifying', finalPath);
        // minify(finalPath, function(err){

          if (err) return callback(err);

          info.src = src;

          callback(null, info);
        // });
      });
    });  
  };
};
{'fraction_non_alphanumeric': 0.15348288075560804, 'fraction_numerical': 0.0011806375442739079, 'mean_word_length': 2.968384074941452, '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': '5893152', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1010, 'n_words': 293}