Skip to content

Instantly share code, notes, and snippets.

@vishalsrini
Last active October 12, 2017 12:10
Show Gist options
  • Save vishalsrini/eb31b404cf59d261d6b4ee83c6c8a14b to your computer and use it in GitHub Desktop.
Save vishalsrini/eb31b404cf59d261d6b4ee83c6c8a14b to your computer and use it in GitHub Desktop.
Typescipt to make use of resize.js. Make sure you added the resize.js in your assets folder and given the reference to your angular-cli in scripts array.
import { Component, ViewChild } from '@angular/core';
declare var $: any;
declare var window;
@Component({
selector: 'app-init',
templateUrl: './app.component.html'
})
export class AppInit {
private base64textString: String = "";
handleFileSelect(evt) {
var files = evt.target.files;
var file = files[0];
var resize = new window.resize();
resize.init();
resize.photo(files[0], 500, 'dataURL', (thumbnail) => {
file = thumbnail;
console.log(file);
this.base64textString = file;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment