From 351b4c7598c689337b8ce2c82543f902f8b30045 Mon Sep 17 00:00:00 2001 From: nkovacic Date: Wed, 28 Sep 2016 15:47:15 +0200 Subject: [PATCH] Added FileResizeOptions for the changed resize function call --- ng-file-upload/ng-file-upload-tests.ts | 12 +++++++++++- ng-file-upload/ng-file-upload.d.ts | 21 +++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ng-file-upload/ng-file-upload-tests.ts b/ng-file-upload/ng-file-upload-tests.ts index f7fdcf1015..ff3044977a 100644 --- a/ng-file-upload/ng-file-upload-tests.ts +++ b/ng-file-upload/ng-file-upload-tests.ts @@ -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); }); diff --git a/ng-file-upload/ng-file-upload.d.ts b/ng-file-upload/ng-file-upload.d.ts index 41b0331dbe..2700a5d206 100644 --- a/ng-file-upload/ng-file-upload.d.ts +++ b/ng-file-upload/ng-file-upload.d.ts @@ -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 // 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} */ - resize(file: File, width?: number, height?: number, quality?: number, type?: string, - ratio?: number | string, centerCrop?: boolean): angular.IPromise; + resize(file: File, options: FileResizeOptions): angular.IPromise; /** * Set the default values for ngf-select and ngf-drop directives *