Comments (9)
Thanks for opening an issue!
I am surprised I did not use this.ctx.getImageData
in the first place. I hope I did not have a good reason to not do so. I totally agree with your implementation, if you can come up with a PR I would be happy to merge it! Also removing the Pillow dependency is good.
Though I think an even more general solution is to use the serializers and traittypes from https://github.com/vidartf/ipydatawidgets
I disagree with this because I don't want ipycanvas to depend on another widgets library. Having users to install one labextension/nbextension is already quite difficult, so asking them to install two of them in order for ipycanvas to work is too much IMO.
from ipycanvas.
It would be nice to compare performances between your solution and the previous one though. I might have used the toBlob
for performances purpose, but I am not sure.
from ipycanvas.
I disagree with this. I don't want to depend on another widgets library. Having users to install one labextension/nbextension is already quite difficult, so asking them to install two of them in order for ipycanvas to work is too much IMO.
100% that installing more than one labextension is no good. Though I don't think that would be necessary. It's not clear from the name but that is broken into separate packages so you can have the traittype and serializers without requiring any jupyter labextension install
steps. There is 1 python package and two different js packages. 1 of them is the extension and widgets, and the other is just the serializers. (related is this issue jupyter-widgets/traittypes#21)
It would be nice to compare performances between your solution and the previous one though. I might have used the toBlob for performances purpose, but I am not sure.
Maybe size was your reason? see: https://stackoverflow.com/a/34924715/835607. given the differences in size maybe it's best to leave as is?
I think that the ndarray traittype gets around by offering a compression option https://github.com/vidartf/ipydatawidgets/blob/69eebeb5647d58dec6bf459d424727cb23cce8ab/packages/serializers/src/ndarray.ts#L167
from ipycanvas.
Is performance also the reason you have sync_image_data
default to False?
from ipycanvas.
Though I don't think that would be necessary. It's not clear from the name but that is broken into separate packages so you can have the traittype and serializers without requiring any jupyter labextension install steps. There is 1 python package and two different js packages. 1 of them is the extension and widgets, and the other is just the serializers. (related is this issue jupyter-widgets/traittypes#21)
Good catch! Then I agree we could depend on the Python package to make things modular :)
Maybe size was your reason? see: https://stackoverflow.com/a/34924715/835607. given the differences in size maybe it's best to leave as is?
Yes that might have been the reason for not using getImageData
directly. Although if you think the compression that happens during the blob transformation is a problem (loss of data?) we should maybe consider using getImageData
instead.
Is performance also the reason you have sync_image_data default to False?
Indeed.
from ipycanvas.
Is performance also the reason you have sync_image_data default to False?
I might be wrong, but I thought that in most of the cases, people would not need to retrieve the image as a NumPy array.
from ipycanvas.
Although if you think the compression that happens during the blob transformation is a problem (loss of data?) we should maybe consider using
getImageData
instead
I think PNG compression is lossless and the conversions that you're using result in PNG compression so that shouldn't be an issue. If you wanted an intermediate to using ipydatawidgets then you can trade the Pillow dep for a typescript one (pako) (like this ianhi/ipysegment@0127f5b) and use the python builtin zlib
. So I guess in the end it's kind of a wash.
I might be wrong, but I thought that in most of the cases, people would not need to retrieve the image as a NumPy array.
That also rings true
from ipycanvas.
Should we close this?
from ipycanvas.
Probably. Feel free to re-open if you ever want to change your image data serialization strategy, but what you have now works, so there's no real need to change it.
from ipycanvas.
Related Issues (20)
- How to get the new path HOT 7
- add width, height support to put_image_data HOT 1
- How to add transform to Path2D HOT 6
- voila fails to load ipycanvas.js from localhost HOT 2
- how to drag an image around on the canvas? HOT 2
- bundle text and shape into one object HOT 4
- ipycanvas does not work with JupyterLab 4 HOT 4
- debug_output only works if calling display(canvas) HOT 1
- ipycanvas 0.13.1 does not work with google colab. 0.13 works. HOT 1
- Take a screenshot of a drawing/canvas and save it? HOT 2
- current canvas out of sync after page reload
- Commands JSON content mangled HOT 3
- Error displaying widget: model not found HOT 1
- is there no call to remove a shape? HOT 1
- bug on canvas.clear() HOT 1
- any way to pause animation? HOT 2
- feature request for mouse drag HOT 2
- Using Path2D for stroke
- Error with fresh jupyterlab 3 install - "Failed to load model class" / "Error: No version of module ipycanvas is registered" HOT 3
- The docs link to github needs updating HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipycanvas.