Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Freezing #12

Open
ranouf opened this issue Sep 20, 2018 · 1 comment
Open

Freezing #12

ranouf opened this issue Sep 20, 2018 · 1 comment

Comments

@ranouf
Copy link

ranouf commented Sep 20, 2018

Hi,

<input style="display: none"
        type="file"
        (change)="onFileChanged($event)"
        [multiple]="allowMultiple"
        [accept]="accept"
        #fileInput>
 <button (click)="fileInput.click()"
         (keyup.enter)="fileInput.click()"
         mat-raised-button
         color="primary"
         type="button">
   <mat-icon>insert_photo</mat-icon>
   ADD IMAGE(S)
 </button>
 public async onFileChanged(event) {
    console.log('onFileChanged', event);
    this.selectedFiles = event.target.files;
    if (!this.selectedFiles) {
      return;
    }

    let files = <File[]>[];
    for (var i = 0; i < this.selectedFiles.length; i++) {
      files.push(this.selectedFiles[i]);
    }

    this.ng2PicaService.resize(files, 50, 50).subscribe((result) => {
      //all good, result is a file
      console.info(result);
    }, error => {
      //something went wrong 
      console.error(error);
    });
}

here is my code to upload new image. when this.ng2PicaService.resize is executed, the tab browser is freezing. My guess is the Web Worker are not enabled.

My angular is configured to use WebWorker, you can see here : https://stackoverflow.com/questions/52414807/resize-and-compress-image-in-angular-6-using-web-worker that it works correctly.

Do you know how to enable this option?

@ranouf
Copy link
Author

ranouf commented Sep 20, 2018

on the Pica documentation: https://github.com/nodeca/pica

It s written:

Webworkers, WebAssembly and createImageBitmap are not required, but they will be used if available.

So it s supposed to work, but the freeze is for me a smell that something is missing somewhere.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant