index.js
function (filters, returnResult) {

		var image,
			newFilters;

		// Convert to array
		if (_.isString(filters)) {
			filters = [filters];
		} else if (!_.isArray(filters) && _.isObject(filters)) {
			filters = [filters];
		}

		// Format array as needed by the function
		newFilters = [];
		(filters || []).forEach(function (filter) {

			if (_.isString(filter)) {
				newFilters.push({key: filter, options: {}});

			} else if (_.isObject(filter)) {
				newFilters.push(filter);
			}
		});
		filters = newFilters;

		// Process filters
		image = this;
		(filters || []).forEach(function (filter) {

			var currentFilter = PNGImage.filters[filter.key];

			if (!currentFilter) {
				throw new Error('Unknown filter ' + filter.key);
			}

			filter.options = filter.options || {};
			filter.options.needsCopy = !!returnResult;

			image = currentFilter(this, filter.options);

		}.bind(this));

		// Overwrite current image, or just returning it
		if (!returnResult) {
			this._image = image.getImage();
		}

		return image;
	}
function (filters, returnResult) {

		var image,
			newFilters;

		// Convert to array
		if (_.isString(filters)) {
			filters = [filters];
		} else if (!_.isArray(filters) && _.isObject(filters)) {
			filters = [filters];
		}

		// Format array as needed by the function
		newFilters = [];
		(filters || []).forEach(function (filter) {

			if (_.isString(filter)) {
				newFilters.push({key: filter, options: {}});

			} else if (_.isObject(filter)) {
				newFilters.push(filter);
			}
		});
		filters = newFilters;

		// Process filters
		image = this;
		(filters || []).forEach(function (filter) {

			var currentFilter = PNGImage.filters[filter.key];

			if (!currentFilter) {
				throw new Error('Unknown filter ' + filter.key);
			}

			filter.options = filter.options || {};
			filter.options.needsCopy = !!returnResult;

			image = currentFilter(this, filter.options);

		}.bind(this));

		// Overwrite current image, or just returning it
		if (!returnResult) {
			this._image = image.getImage();
		}

		return image;
	}
function ( filters , returnResult ) { var image , newFilters ; // Convert to array if ( _ . isString ( filters ) ) { filters = [ filters ] ; } else if ( ! _ . isArray ( filters ) && _ . isObject ( filters ) ) { filters = [ filters ] ; } // Format array as needed by the function newFilters = [ ] ; ( filters || [ ] ) . forEach ( function ( filter ) { if ( _ . isString ( filter ) ) { newFilters . push ( { key : filter , options : { } } ) ; } else if ( _ . isObject ( filter ) ) { newFilters . push ( filter ) ; } } ) ; filters = newFilters ; // Process filters image = this ; ( filters || [ ] ) . forEach ( function ( filter ) { var currentFilter = PNGImage . filters [ filter . key ] ; if ( ! currentFilter ) { throw new Error ( 'Unknown filter ' + filter . key ) ; } filter . options = filter . options || { } ; filter . options . needsCopy = ! ! returnResult ; image = currentFilter ( this , filter . options ) ; } . bind ( this ) ) ; // Overwrite current image, or just returning it if ( ! returnResult ) { this . _image = image . getImage ( ) ; } return image ; }
Applies a list of filters to the image

@method applyFilters
@param {string|object|object[]} filters Names of filters in sequence `{key:<string>, options:<object>}`
@param {boolean} [returnResult=false]
@return {PNGImage}
Applies a list of filters to the image