cstefanache / angular2-img-cropper

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

The resulting image sometimes has dimensions different from the preview #230

Open parker-mike opened 6 years ago

parker-mike commented 6 years ago

The plnkr is available here and the image for example Try to make the cropping frame to be as small as the defined in the code constraints allow you, open the DevTools an select in the DOM the preview image node, now you can play a bit with the location(don't touch the size) of the cropping frame and you will see that at some locations the height or the width changes its' value by one px and it won't match the dimensions of the resulting image, like so(look at the height vs natural height, which is 66 in the preview vs 67 in the resulting image): image Actually, you can just select that file, and check the dimensions of the resulting image and the preview right away, you will see that the preview is set to be 200x92 when the natural size is 199x92. The other thing is that the frame doesn't get the size it was defined, like in the example it should be 130x60 but as I mentioned the size it gets is 199x92, for some unknown reason, moreover I need the resulting image to be with a defined aspect ratio(so I set the keepAspect), which is expected to be 2.5 in my example, but already the initial dimensions of the cropping frame show that it's different.

By the way, the README.md has a sample link to plnkr with an old version of the library, should be updated, and it doesn't have a description for keepAspect setting. Also, the current version of the package on the unpkg.com is only accessible through index with no .ts extension(404 for https://unpkg.com/ng2-img-cropper@0.9.0/index.ts but 200 for https://unpkg.com/ng2-img-cropper@0.9.0/index), meaning that in config.js the package configuration for the library should be as follows:

'ng2-img-cropper': {
  main: 'index',
  //defaultExtension: 'ts'
},