OGeek|极客世界-中国程序员成长平台

标题: android - Cordova 以黑色区域顶部和底部返回横向照片 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 16:25
标题: android - Cordova 以黑色区域顶部和底部返回横向照片

有没有办法配置Cordova camera plugin返回没有超出目标高度的黑带的照片?

例如, enter image description here

这样设置选项时返回:

var options = {
        quality: 100,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.CAMERA,
        allowEdit: true,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 800,
        targetHeight: 1200,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: false,
        correctOrientation: true
      };
$cordovaCamera.getPicture(options).then(function (imageURI) {});

我已尝试删除 targetWidthtargHeight 参数。您无法提前知道照片是横向还是纵向的一个问题。

这是一个一年前从未回答过的问题:Phonegap Camera returns photo with black bars



Best Answer-推荐答案


不要使用 allowEdit 选项或将其设置为 false

当您使用 allowEdit: true, 时,它会将您带到一个裁剪屏幕,该屏幕将创建一个方形图像,如果您不缩放图像来裁剪它,它会在其上添加黑色区域顶部和底部使图像成为正方形

关于android - Cordova 以黑色区域顶部和底部返回横向照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37144570/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4