<commit_before>(function(){

    var qt = {},
        fs = require('fs'),
        path = require('path'),
        mkdirp = require('mkdirp'),
        im = require('imagemagick');


    module.exports = qt;


    // Take an image from src, and write it to dst
    qt.convert = function(options, callback){
        var src = options.src,
            dst = options.dst,
            width = options.width,
            height = options.height,
            quality = options.quality,
            type = options.type || 'crop';

        mkdirp(path.dirname(dst));

        var im_options = {
                srcPath : src,
                dstPath : dst
            };

        if (options.width) im_options.width = width;
        if (options.height) im_options.height = height;
        if (options.quality) im_options.quality = quality;

        try{
            im[type](im_options, function(err, stdout, stderr){
                if (err){
                    return callback(err);
                }
                callback(null, dst);
            });
        }
        catch(err){
            return callback('qt.convert() ERROR: ' + err.message);
        }
    };


    // express/connect middleware
    qt.static = function(root, options){

        var root = path.normalize(root),
            cache_root = path.join(root, '.cache');

        options || ( options = {
            type : 'crop'
        });

        return function (req, res, next){
            var file = req.url.replace(/\?.*/,''),
                dim = req.query.dim,
                orig = path.normalize(root + file),
                dst = path.join(cache_root, options.type, dim, file);

            function send_if_exists(file, callback){
                fs.exists(file, function(exists){
                    if (!exists){
                        return callback();
                    }

                    fs.stat(file, function(err, stats){
                        if (err){
                            console.error(err);
                        }
                        else if (stats.isFile()){
                            return res.sendfile(file);
                        }
                        callback();
                    });
                });<commit_msg>Fixed a bug improving compatibility<commit_after>(function(){

    var qt = {},
        fs = require('fs'),
        path = require('path'),
        mkdirp = require('mkdirp'),
        im = require('imagemagick');


    module.exports = qt;


    // Take an image from src, and write it to dst
    qt.convert = function(options, callback){
        var src = options.src,
            dst = options.dst,
            width = options.width,
            height = options.height,
            quality = options.quality,
            type = options.type || 'crop';

        mkdirp(path.dirname(dst));

        var im_options = {
                srcPath : src,
                dstPath : dst
            };

        if (options.width) im_options.width = width;
        if (options.height) im_options.height = height;
        if (options.quality) im_options.quality = quality;

        try{
            im[type](im_options, function(err, stdout, stderr){
                if (err){
                    return callback(err);
                }
                callback(null, dst);
            });
        }
        catch(err){
            return callback('qt.convert() ERROR: ' + err.message);
        }
    };


    // express/connect middleware
    qt.static = function(root, options){

        var root = path.normalize(root),
            cache_root = path.join(root, '.cache');

        options || ( options = {
            type : 'crop'
        });

        return function (req, res, next){
            var file = req.url.replace(/\?.*/,''),
                dim = req.query.dim || "",
                orig = path.normalize(root + file),
                dst = path.join(cache_root, options.type, dim, file);

            function send_if_exists(file, callback){
                fs.exists(file, function(exists){
                    if (!exists){
                        return callback();
                    }

                    fs.stat(file, function(err, stats){
                        if (err){
                            console.error(err);
                        }
                        else if (stats.isFile()){
                            return res.sendfile(file);
                        }
                        callback();
                    });
                });
{'fraction_non_alphanumeric': 0.11941618752764263, 'fraction_numerical': 0.0, 'mean_word_length': 1.1988332523091882, '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': '7202589', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1107, 'n_words': 262}