function resizeWithParams(param, files, attr, scope) { var promises = [upload.emptyPromise()]; function handleFile(f, i) { if (f.type.indexOf('image') === 0) { if (param.pattern && !upload.validatePattern(f, param.pattern)) return; var promise = upload.resize(f, param.width, param.height, param.quality, param.type, param.ratio, param.centerCrop, function (width, height) { return upload.attrGetter('ngfResizeIf', attr, scope, {$width: width, $height: height, $file: f}); }, param.restoreExif !== false); promises.push(promise); promise.then(function (resizedFile) { files.splice(i, 1, resizedFile); }, function (e) { f.$error = 'resize'; f.$errorParam = (e ? (e.message ? e.message : e) + ': ' : '') + (f && f.name); }); } } for (var i = 0; i < files.length; i++) { handleFile(files[i], i); } return $q.all(promises); }
data.canvas.toBlob( function (blob) { if (!blob.name) { if (file.type === blob.type) { blob.name = file.name; } else if (file.name) { blob.name = file.name.replace( /\.\w+$/, '.' + blob.type.substr(6) ); } } // Don't restore invalid meta data: if (file.type !== blob.type) { delete data.imageHead; } // Store the created blob at the position // of the original file in the files list: data.files[data.index] = blob; dfd.resolveWith(that, [data]); }, options.type || file.type, options.quality );
(!isBackground || file.type.indexOf('image') === 0)) { if (size && Upload.isResizeSupported()) { Upload.resize(file, size.width, size.height, size.quality).then( function (f) { constructDataUrl(f);
/** * @inheritdoc * @override */ parseCLIOptions(options, command) { options.quality = command.quality; }
/** * Colorize the given string according to the provided item's quality * @param {Item} item * @param {string} string * @return {string} */ static qualityColorize(item, string) { const colors = this.qualityColors()[item.metadata.quality || 'common']; const open = '<' + colors.join('><') + '>'; const close = '</' + colors.reverse().join('></') + '>'; return open + string + close; }
//Main class function FSWebcam( options ) { var scope = this; scope.opts = Utils.setDefaults( options, FSWebcam.Defaults ); Webcam.call( scope, scope.opts ); if( scope.opts.output === "png" && scope.opts.quality > 9 ) { scope.opts.quality = 9; } }
function encodeJpeg(image, options = {}) { const data = { width: image.width, height: image.height, data: image.getRGBAData(), }; return realEncodeJpeg(data, options.quality).data; }
/** * @inheritdoc * @override */ parseAPIOptions(options) { if (typeof options.quality === 'number' && (options.quality < 0 || options.quality > 100)) { throw new Error('Value for quality option out of range. Use value between 0-100 (inclusive)'); } if (options.quality == null) { options.quality = 100; } }
/** * @inheritdoc * @override */ parseCLIOptions(options, command) { options.quality = command.quality; }