简体   繁体   English

angular-img-cropper无法在方形图片的方形裁剪上设置裁剪尺寸工具

[英]angular-img-cropper failing to set crop size tool on squared crop with square picture

We are using https://github.com/AllanBishop/angular-img-cropper and so far, its has been great, but today we stumble into a bug, basically, when you load a squared image like this one: 我们正在使用https://github.com/AllanBishop/angular-img-cropper ,到目前为止,它一直都很棒,但今天我们偶然发现了一个bug,当你加载像这样的平方图像时:

在此输入图像描述

The cropper tool becomes tiny and almost impossible to use, and if you click the yellow cross, its goes insanely big. 裁剪工具变得很小,几乎不可能使用,如果你点击黄色十字架,它会变得非常大。

在此输入图像描述 在此输入图像描述

We just posted the bug on the dev's git https://github.com/AllanBishop/angular-img-cropper/issues/93 我们刚刚在dev的git上发布了这个bug https://github.com/AllanBishop/angular-img-cropper/issues/93

The bug is easily replicated using devs bin https://github.com/AllanBishop/angular-img-cropper just go there, modify the html to have this parameters in the canvas crop-width="720" crop-height="720" and load the first iamge on the post image. 使用devs bin https://github.com/AllanBishop/angular-img-cropper可以轻松复制该bug,只需去那里,修改html,使画布中的参数为crop-width =“720”crop-height =“720 “并在帖子图片上加载第一个iamge。

The best solution was to add a white image for a .5 seconds while the cropper tool gets initialized, then set the image that the user actually selected using a timeout. 最佳解决方案是在裁剪工具初始化时添加白色图像0.5秒,然后使用超时设置用户实际选择的图像。

vm.setCropperImage =  function(imgBase64) {
            var imgPlaceholder = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAAqCAIAAACY8VRUAAAAA3NCSVQICAjb4U/gAAAASUlEQVRYhe3OsQ3AIBAAsZD9d35WoDgJCnsCr5n5nvffDhyx7Fh2LDuWHcuOZceyY9mx7Fh2LDuWHcuOZceyY9mx7Fh2LDuWnQ30YQNRzV7JZAAAAABJRU5ErkJggg==';  
            vm.cropper.sourceImage = imgPlaceholder;

            $timeout(function() {
                vm.cropper.sourceImage = imgBase64;
                $scope.ngModel = imgBase64;
            }, 50);
        };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM