Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 8 and imageSmoothingQuality #55

Closed
marie-dk opened this issue Feb 5, 2020 · 2 comments
Closed

Angular 8 and imageSmoothingQuality #55

marie-dk opened this issue Feb 5, 2020 · 2 comments

Comments

@marie-dk
Copy link

marie-dk commented Feb 5, 2020

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
Copy link
Owner

matheusdavidson commented Feb 5, 2020

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
Copy link
Author

marie-dk commented Feb 6, 2020

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

@marie-dk marie-dk closed this as completed Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants