cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Is it possible to initialize cropper with external image url? #269

Open IrynaBu opened 6 years ago

IrynaBu commented 6 years ago

The problem from https://github.com/cstefanache/angular2-img-cropper/issues/110 still exist. client code

    const image: HTMLImageElement = new Image();
    image.addEventListener('load', (data) => {
      image.crossOrigin = "anonymous"; // or image.crossOrigin = "Anonymous";
      this.cropper.setImage(image);
    });
    image.src = this.config.image;

Also i try to add this.cropper.image.crossOrigin = "anonymous" still no lucky(

mibzman commented 6 years ago

I had the same issue today. Please note that this is not an issue with the image cropper itself, but a server-side CORS issue.

I was trying to load images from AWS s3 (which has awful CORS support), and I ended up building my own image proxy following the guidance here.

I then used this with:

    var image:any = new Image();
    image.crossOrigin = "Anonymous";
    image.onload = function(){
      that.cropper.setImage(image)
    }
    image.src = `${YOUR_PROXY}?url=${URL}`