Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用ng2图像工具的_扩展无效_Javascript_Angular_Typescript - Fatal编程技术网

Javascript 使用ng2图像工具的_扩展无效

Javascript 使用ng2图像工具的_扩展无效,javascript,angular,typescript,Javascript,Angular,Typescript,我用的是离子2 我从firebase检索图像 但是我需要调整这些图片的大小 这是我的功能 var someImage:any="https://firebasestorage.googleapis.com/v0/b/apartments-ea9e5.appspot.com/o/admin%2Fsample-1487416146311.jpg?alt=media&token=e61d2573-acd2-4284-b0b3-f45a1fc450cc"; this.ng2ImgToo

我用的是离子2

我从firebase检索图像

但是我需要调整这些图片的大小

这是我的功能

var someImage:any="https://firebasestorage.googleapis.com/v0/b/apartments-ea9e5.appspot.com/o/admin%2Fsample-1487416146311.jpg?alt=media&token=e61d2573-acd2-4284-b0b3-f45a1fc450cc";
     this.ng2ImgToolsService.resize([someImage], 100, 100).subscribe(result => {
            //all good, result is a file
            console.info(result);
        }, error => {
          console.log("err");
          console.log(error);
            //something went wrong 
            //use result.compressedFile or handle specific error cases individually
        })
我犯了这个错误

如何解决此问题。或任何其他调整图像大小的方法

error:INVALID_EXTENSION

reason: "The provided File is neither of type jpg nor of type png."

好吧,我遇到了同样的问题,我修复了这个问题,如下所示

我有一个名为originalImage的文件(通过文件上传获得),我将它克隆到另一个名为modifieldImage的文件中

克隆的代码如图所示

const modifieldImage= new File(
          [uploadImage.originalImage],
          uploadImage.originalImage.name,
          {
            type: uploadImage.originalImage.type
          }
        );
//then call the api
this.ng2ImgMax .resizeImage(modifieldImage, 1600, 1176) ...
创建文件时尝试添加“类型”。这应该可以解决问题。

在您的场景中,我相信“someImage”类型是空的。尝试将其克隆到另一个文件并在FilePropertyBag中添加类型

希望它能帮助别人