jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
688 stars 64 forks source link

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

Closed AnyaPorter closed 1 month ago

AnyaPorter commented 4 months ago

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 #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.

github-actions[bot] commented 4 months ago

lite-badge :point_left: Try it on ReadTheDocs with JupyterLite!

AnyaPorter commented 4 months ago

Thanks for the comments! Updated as per your suggestions.

martinRenou commented 1 month ago

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