matheusdavidson / angular-cropperjs

CropperJS integration for Angular +6
MIT License
109 stars 69 forks source link

Angular 8 and imageSmoothingQuality #55

Closed marie-dk closed 4 years ago

marie-dk commented 4 years ago

Angular 7 -> 8 update I just updated my project to Angular 8, but the update procedure complained about angular-cropperjs not being compatible.

# ng update @angular/cli @angular/core

Package "angular-cropperjs" has an incompatible peer dependency to "@angular/core" (requires "^6.0.0-rc.0 || ^6.0.0" (extended), would install "8.2.14").

Then I realized that I've successfully been using this package with Angular 7. So I went along and added --force to the update command, and everything worked out just fine.

Using imageSmoothingQuality The following is probably not related to Angular 8: I needed to add imageSmoothingQuality as an option for getCroppedCanvas. According to the Cropper JS docs, this option takes a string value of either "low", "medium" or "high".

But I got this error:

Type '"low"' is not assignable to type 'ImageSmoothingQuality'

In the file index.d.ts(15) there is a type defined for this value:

enum ImageSmoothingQuality {
    Low = 'low',
    Medium = 'medium',
    High = 'high',
  }

.. which is used in the interface at index.d.ts(65):

export interface GetCroppedCanvasOptions {
    width?: number;
    height?: number;
    minWidth?: number;
    minHeight?: number;
    maxWidth?: number;
    maxHeight?: number;
    fillColor?: string;
    imageSmoothingEnabled?: boolean;
    imageSmoothingQuality?: ImageSmoothingQuality;
  }

No matter how I tried, I could not make it work. So I ended up changing the type to "string" in the above interface:

imageSmoothingQuality?: string;

And now it works like a charm... I wonder why this custom type is necessary when the underlying cropper just expects a string?

Thank you... ... for this fantastic package. I can't encourage you enough to update the compatible versions and maybe fix it a bit here and there. I think it still has a few years in it :-)

matheusdavidson commented 4 years ago

Hi there, i'm planning to do a good refactor in this lib and add some new other cool features, didn't had much time lately but i will do it very soon in the next weeks. It will be available for angular 8 and upcoming 9, hold on for a bit, i will include that fix in the new version.

Thank you

marie-dk commented 4 years ago

Awesome. That's good news... you just made my day :-D