Merge pull request #11561 from nkovacic/ng-file-upload

Added FileResizeOptions for the changed resize function call
This commit is contained in:
John Reilly
2016-09-28 15:06:47 +01:00
committed by GitHub
2 changed files with 28 additions and 5 deletions
+11 -1
View File
@@ -78,7 +78,17 @@ class UploadController {
fileWithNewName = this.Upload.rename(files[0], "newName.jpg");
this.Upload
.resize(files[0], 1024, 1024, 0.7, 'image/jpeg', 0.9, true)
.resize(files[0], {
height: 1024,
width: 1024,
quality: 0.7,
ratio: 0.9,
centerCrop: true,
restoreExif: true,
resizeIf: (width, height) => {
return true;
}
})
.then((resizedFile) => {
console.log(resizedFile);
});
+17 -4
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular File Upload 11.1.1
// Type definitions for Angular File Upload 12.2.12
// Project: https://github.com/danialfarid/ng-file-upload
// Definitions by: John Reilly <https://github.com/johnnyreilly>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -92,6 +92,20 @@ declare namespace angular.angularFileUpload {
ngfValidateForce?: boolean;
}
interface ResizeIfFunction {
(width: number, height: number): boolean;
}
interface FileResizeOptions {
centerCrop?: boolean;
height?: number;
ratio?: number;
resizeIf?: ResizeIfFunction;
restoreExif?: boolean;
quality?: number;
width?: number;
}
interface IUploadService {
/**
* Convert a single file or array of files to a single or array of
@@ -166,7 +180,7 @@ declare namespace angular.angularFileUpload {
* @param {string} newName
* @return {File}
*/
rename(file: File, newName: string): File;
rename(file: File, newName: string): Blob;
/**
* Resizes an image. Returns a promise
*
@@ -179,8 +193,7 @@ declare namespace angular.angularFileUpload {
* @param {boolean} [centerCrop]
* @return {angular.IPromise<string>}
*/
resize(file: File, width?: number, height?: number, quality?: number, type?: string,
ratio?: number | string, centerCrop?: boolean): angular.IPromise<string>;
resize(file: File, options: FileResizeOptions): angular.IPromise<File>;
/**
* Set the default values for ngf-select and ngf-drop directives
*