cstefanache / angular2-img-cropper

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

Responsive ImageCropper doesn't recalculate bounds on setImage() #173

Open DoKraus opened 7 years ago

DoKraus commented 7 years ago

First of all: great work with this module!

I don't know if this is an issue or I use that module in an incorrect way. I try to set an existing image for the ImageCropper - which works fine. In addition, I want to set the "initial"-bounds for that image (see issue #97).

Obviously it's possible via this.imageCropper.setImage(myImage, myBounds); I assume, the bounds are relative to the original image size?

If then: cool story - but it fails if the canvas is smaller (or in another size) as the image.

I use an image with the size of 1920x1080 and "default"-bounds: { x: 10, y: 10, w: 500, h: 500 }. The generated canvas has a size of 427x213. The only marker visible is top-left - the other ones are not shown in the canvas With following bounds: { x: 10, y: 10, w: 400, h: 180 } all markers are shown in the canvas.

So I assume the bounds are not recalculated for the fitting canvas ... Thanks in advance for every help!

edit3: I tried following: I added this.cropper.updateCropPosition(bounds); after the line self.cropper.setBounds(bounds); in the imageCropperComponent.ts and it seems, it works ...