bergben / ng2-img-max

Angular 2 module to resize images down to a certain width and height or to reduce the quality to fit a certain maximal filesize - all in the browser.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

INVALID_EXTENSION - .jpg

polfernandez opened this issue · comments

When I try to resize/compress a .jpg file from an android device, I keep getting "INVALID_EXTENSION" error. But for .png, or .jpeg files works fine.

Output:

Input image
Blob(225073) {size: 225073, type: "image/jpg"} size: 225073 type: "image/jpg" __proto__: Blob
Output error
{compressedFile: Blob(225073), reason: "File provided is neither of type jpg nor of type png.", error: "INVALID_EXTENSION"} {resizedFile: Blob(225073), reason: "The provided File is neither of type jpg nor of type png.", error: "INVALID_EXTENSION"}

Having the exact same issue. Is the package working?

Well, I had faced the same issue I fixed this issue as shown below.

I had File called originalImage, i clone it to another File called modifieldImage

the code for the clone is as shown

const modifieldImage= new File(
          [uploadImage.originalImage],
          uploadImage.originalImage.name,
          {
            type: uploadImage.originalImage.type
          }
        );

//then call the api
this.ng2ImgMax .resizeImage(modifieldImage, 1600, 1176) ...



** try adding the 'type' while creating the File. That may fix the issue. **


Hope it helps someone.