Closed gfranco93 closed 8 years ago
This is just when you initialize the cropper. Using my method, you can set a new image whenever needed without re-instantiating the cropper. I would say this fix is not really needed.
You're right when you say that it's just for initializing the cropper, I made it that way because of the plunker (this.data = {};
).
Using you idea you will have to add 'cropper' to the outputs of ImageCropperComponent (to avoid creating the ImageCropper outside of ImageCropperComponent), am I right?
I think both ideas can coexist, could you upload a PR?
Yes both of them can coexist. I don't need to upload a PR because you can already implement my solution also.
Here is a quick example:
<div class="row">
<img-cropper [image]="data" [settings]="cropperSettings" [cropper]="cropper"></img-cropper>
<br>
<img [src]="data.image" >
</div>
and:
public cropper: ImageCropper;
and in constructor:
this.cropper = new ImageCropper(0, 0, this.cropperSettings.width, this.cropperSettings.height,
this.cropperSettings.croppedWidth, this.cropperSettings.croppedHeight, this.cropperSettings.keepAspect);
And in a method where you want to add the new image for cropp:
let imgObj = new Image();
imgObj.src = 'data:image/png;base64,' + templateFile.fileData;
this.cropper.setImage(imgObj);
Great!
Is this still an issue?
No, closing.
Addressing closed issue 18 from user @Mihai-B :
You just need to set the image from your app.component:
this.data = {"image":YourImage};