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

Added grayscale image support in put_image_data and exposed image_smoothing_enabled attribute #348

Closed
wants to merge 0 commits into from

Conversation

AnyaPorter
Copy link
Contributor

In setting up ipycanvas to use in a long-term project I had a couple of options that I think could be beneficial to others.

  1. I added grayscale image support in put_image_data so you can now pass in a 2D numpy array instead of being limited to 3D for rgb or rgba (closes Supporting grayscale images from numpy #346)
  2. I added image_smoothing_enabled to echo the Web Canvas API imageSmoothingEnabled, which is supported in all browser types as per the documentation. This allows users to have a similar result to PIL's RESAMPLING.NEAREST when enlarging an image as opposed to the automatic smoothing that occurs now.

Its my first time working directly with TypeScript/JavaScript so happy to have feedback on a better/preferred way to do what I did and especially on how to test it as I was not sure how to get it to use the forked version aside from installing directly from the github fork. I am happy to update as needed.

Copy link
Contributor

lite-badge 👈 Try it on ReadTheDocs with JupyterLite!

Copy link
Collaborator

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have a couple of suggestions

ipycanvas/canvas.py Outdated Show resolved Hide resolved
ipycanvas/canvas.py Outdated Show resolved Hide resolved
src/widget.ts Outdated Show resolved Hide resolved
@AnyaPorter
Copy link
Contributor Author

Thanks for the comments! Updated as per your suggestions.

Copy link
Collaborator

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry for the delay

@martinRenou
Copy link
Collaborator

I made a mistake, will reopen your PR and credit you

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

Successfully merging this pull request may close these issues.

Supporting grayscale images from numpy
2 participants