digitalascetic / ngx-pica

@digitalascetic/ngx-pica is an Angular(LTS) module to resize images files in browse
36 stars 26 forks source link

image gets a black part after compressImage #4

Closed pharindoko closed 6 years ago

pharindoko commented 6 years ago

Hi,

first of all thanks for this library: It`s easy to use. second: my issue :)

Usage

I`m using it like this for an image upload function on the mobile phone:

  onImageChange(event) {
    const images = [];
    for (let i = 0; i < event.target.files.length; i++) {
      images.push(event.target.files[i]);
    }
    this._ngxPicaService.compressImages(images, 2.500).subscribe(
      result => {
        const imagefile = new File([result], result.name);
        this.uploadedImages.push(imagefile);
        this.getImagePreview(imagefile);
      },
      error => {
        console.log('😢 Oh no!', error);
      }
    );

Issue

the image gets a black part on the right side. So it seems like the width is incorrect This does only happen if the width is smaller than the height.

2018-07-21-04-50-23

edezacas commented 6 years ago

@pharindoko I've tested with different format images and seems all ok. Can you share with us your image?

pharindoko commented 6 years ago

Hey,

image you can see has been made with an iphone. It makes no difference if the photo is directly taken or if I use a photo from the photo gallery.

Purpose: Target is to have an image gallery as mobile web app and these photos can be uploaded.

edezacas commented 6 years ago

@pharindoko Finally I've be able to test on my mobile and compressImage doesn't work correctly on mobile devices and portrait images. I think the problem is the orientation of the photo. If you compare your photos, you can see that width and height are crossed.

pharindoko commented 6 years ago

Yeah that sounds reasonable. @edezacas thanks for being helpful!

edezacas commented 6 years ago

Fixed image orientation for mobile devices. Now compression method works fine. Close issue.