@summary Handle GZ compressed images
@function
@public
@memberof handlers

@param {String} file - file path
@fulfil {Object} - image metadata
@returns {Promise}
174127
function(file) {
    return Bluebird.props({
      stream: fs.createReadStream(file),
      size: fs.statAsync(file).get('size'),
      estimatedUncompressedSize: gzipUncompressedSize.fromFileAsync(file),
      transform: Bluebird.resolve(zlib.createGunzip())
    });
  }
985552
function previewfile(file) {
    if (false && tests.filereader === true) {
      var reader = new FileReader();
      reader.onload = function (event) {
        var image = new Image();
        image.src = event.target.result;
        image.width = 250; // a fake resize
        holder.appendChild(image);
      };

      reader.readAsDataURL(file);
    }  else {
      holder.innerHTML += '<p>Uploaded ' + file.name + ' ' + (file.size ? (file.size/1024|0) + 'K' : '');
//      console.log(file);
    }
  }
1025549
function encodeFileToJson(file) {
    var filePath = file.getPath();
    if (!filePath) {
        return undefined;
    }

    return {
        path: filePath,
        mtime: file.getMTime(),
        type: file.getType()
    };
}
624509
function(file, callback) {
		var that = this;
		
		this.png_encode.encode(this, function (data) {
			var fd = that.fs.openSync(file, 'w');
			for(var i = 0; i < data.length; i++) {
				that.fs.writeSync(fd, data[i], 0, data[i].length);
			}
			that.fs.closeSync(fd);
			
			if(callback) {
				callback.call(that);
			}
		});
	}
894028
function readFile(file) {
	return new Promise(
		(resolve, reject) => {
			fs.readFile(
				file, 'utf8', (error, contents) => {
					if (error) {
						reject(error);
					} else {
						// console.log('readFile', [file, contents]);
						resolve(contents);
					}
				}
			)
		}
	);
}
87190
function minify( file, options, done ){
		if (_.isFunction(options)){
			done = options;
			options = {};
		}
		if (!_.isObject(options))
			options = {};
		if (!_.isFunction(done))
			done = function(){};

		const canOptimize = options.optimize;
		delete options.optimize;

		console.log("  minify file %s...".grey, file);
		try {
			var code   = fs.readFileSync( file, {encoding: 'utf8'} );
			var minify = UglifyJS.minify( code, options );
		} catch (e) {
			return done(  new Error(`Error on parse file ${e.filename}`) );
		}

		if ( !minify || minify.error ) {
			if ( minify && minify.error )
				return done( new Error(minify.error.message) );
			return done(new Error('Minify error bundle.js') );
		}

		try{
			if ( canOptimize ){
				console.log("  optimize file %s...".grey, file );
				code = optimizeJs(minify.code);
			}else{
				code = minify.code;
			}
		}catch(e){
			console.error("Error on parse file %s", e.filename);
			return next(e);
		}

		fs.writeFile(
			file,
			code,
			function (err) {
				if ( err )
					return done(err);


				return done();
			}
		);
	}
592794
function readPNG(file) {
    const deferred = Q.defer();
    const onerror = deferred.reject.bind(deferred);
    const stream = fs.createReadStream(file);
    stream.on("error", onerror);
    pngparse.parseStream(stream, function(err, image) {
        if (err) {
            console.log("Failed to load " + file);
            onerror(err);
            return;
        }
        deferred.resolve(image);
    });
    return deferred.promise;
}
842468
function imageFilter (item /*{File|FileLikeObject}*/, options) {
      var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
      if ('|jpg|png|jpeg|bmp|gif|'.indexOf(type) === -1) {
        var err = new Error('File extension not supported (' + type + ')');
        vm.onUploadFinished(err);
        throw err;
      }

      return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
    }
573088
function isImage(file) {
        var valid = true,
          // formats = _module.options.formats || ['csv', 'xls', 'zip', 'kml', 'kmz', 'gpx', 'lut', 'stl', 'dxf', 'txt', 'pdf', 'svg', 'doc', 'ppt', 'gif', 'png', 'jpg', 'jpeg'],
          formats = _module.options.formats || ["gif", "png", "jpg", "jpeg"],
          filetype = file.name.split(".")[file.name.split(".").length - 1];
        filetype = filetype.toLowerCase();
        if (formats.indexOf(filetype) === -1) valid = false;
        return valid;
      }
672468
function (file) {
        var self = this,
            ext = path.extname(file.name).toLowerCase();
        return this.isZip(ext) ? self.processZip(file) : self.processFile(file, ext);
    }
756935
function handleGetFile(file, text) {
    var next = fileCallBacks[file];
    if (next) {
        try {
            next(null, text);
        } catch (e) {
            _reportError(e, file);
        }
    }
    delete fileCallBacks[file];
}
180348
function(file) {
      var defer = new $.Deferred(),
        size = file.size,
        $image = $('<img>'),
        onImageLoaded = function() {

          log('File Loaded:' + src);
          _bytesLoaded += size;
          onElementLoaded(file, this);
          // removing the file from the array
          _files[_currentSegment].splice(0, 1);
          updatePercentage();
          defer.resolve();

        },
        onImageError = function() {
          log('File load error : ' + src);
          _bytesLoaded += size;
          // removing the file from the array
          _files[_currentSegment].splice(0, 1);
          updatePercentage();
          defer.resolve();
        },
        src;

      // load the svg or the fallback image
      if (file.source.toString() === '[object Object]') {
        if (file.source.svg && _support.svg) {
          src = file.source.svg;
        } else if (file.source.fallback) {
          src = file.source.fallback;
        }
      } else {
        src = file.source;
      }

      $image.on('load', onImageLoaded);
      $image.on('error', onImageError);
      $image.attr('src', src);

      // preventing a memory leak
      $image = null;

      return defer.promise();
    }
1076968
function(file) {
        var self = this;

        return new Promise(function(resolve) {
            fs.readFileAsync(file, 'utf-8')
                .then(function(content) {
                    return self._parseFile(file, content);
                })
                .then(function(ast) {
                    return self._getConfig(file, ast);
                })
                .then(function(config) {
                    self._modules = self._modules.concat(config);

                    resolve(config);
                });
        });
    }
526444
function(file) {
        var type =  '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
        return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
      }
896455
function compress(file) {
  var ext = path.extname(file),
    res,
    source,
    result;

  switch (ext) {
    case '.js':
      console.log('uglifying js file ' + file);

      res = ngAnnotate(String(fs.readFileSync(file, 'utf8')), {
        add: true
      });
      result = UglifyJS.minify(res.src, hookConfig.uglifyJsOptions);
      fs.writeFileSync(file, result.code, 'utf8'); // overwrite the original unminified file
      break;

    case '.css':
      console.log('minifying css file ' + file);

      source = fs.readFileSync(file, 'utf8');
      result = cssMinifier.minify(source);
      fs.writeFileSync(file, result.styles, 'utf8'); // overwrite the original unminified file
      break;

    default:
      console.log('encountered a ' + ext + ' file, not compressing it');
      break;
  }
}
271658
function (file, that) {
				$.ajax({
					type: "post",
					url: that.options.imagesDeleteScript,
					data: {
						file: file
					}
				});
			}
822456
function handleImageLoad(canvas, filename, e) {
        e.preventDefault();

        downloadCanvas(drawImageOnCanvas(this, canvas), filename);
    }