fengyuanchen / cropperjs

JavaScript image cropper.
https://fengyuanchen.github.io/cropperjs/
MIT License
13.14k stars 2.42k forks source link

cropper-viewer option to behave like like css background-size: cover #1214

Closed ronnievdc closed 9 hours ago

ronnievdc commented 4 days ago

Is your feature request related to a problem? Please describe. I like to use Cropper to show previews of the cropped image as they would appear in an environment where the final image is displayed with the following css background-size: cover; background-position: center center;

Describe the solution you'd like Extend the cropper-viewer -> resize property with "cover" and "contain" Add a second property position where center center or other background-position values can be filled

Describe alternatives you've considered Call CropperSelection.$toCanvas each change (debounced) and create a canvas with object-fit: cover

Additional context Screenshot 2024-11-19 at 14-24-55 Title

fengyuanchen commented 9 hours ago

Not support that. A CropperViewer should be connected to a CropperSelection and change as the selection changes.