-
Notifications
You must be signed in to change notification settings - Fork 13
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
Saving layers as svg fails with text labels and color images #50
Comments
Thanks for the issue @Micro-Sandworms! I've transferred it to napari-svg which is its own repo. Are you able to contribute a fix for the image issue? That would be much appreciated! I don't know all that much about svg but I imagine it's not too hard to add text, so it would be a matter of (a) looking for any text annotations on the layer, and (b) saving those in the appropriate part of the xml. |
Thank you, Juan. As I mentioned, replacing the function 'extrema_image' in 'layer_to_xml.py' with def extrema_image(image, meta):
"""Compute the extrema of an image layer, accounting for transforms."""
coords = np.array([[0, 0], list(image.shape[:2])])
return extrema_coords(coords, meta) It worked for me, but I am not in a position to foresee possible negative consequences down the line. Still, I made a commitment with this suggestion. |
@Micro-Sandworms oh thanks, I more meant, would you like to make a pull request to the repo? Here's a good guide for how to do that, if you are not familiar with the process: https://www.dataschool.io/how-to-contribute-on-github/ |
I made two pull requests. One is for a possible solution regarding the color images, and the other is for the text labels. |
🐛 Bug Report
When saving layers as svg, the program crashes if one of the layers contains a color image. In addition, text labels are not saved.
The former can be solved by changing the code at the layer_to_xml.py, function
def extrema_image(image, meta):
"""Compute the extrema of an image layer, accounting for transforms."""
coords = np.array([[0, 0], list(image.shape)]) # This does not work for color images
#coords = np.array([[0, 0], list(image.shape[:2])]) # This works
return extrema_coords(coords, meta)
The later, I don't see how to solve, and I appreciate your help in advance.
💡 Steps to Reproduce
💡 Expected Behavior
No response
🌎 Environment
napari: 0.5.5
Platform: Windows-10-10.0.19045-SP0
Python: 3.11.11 | packaged by conda-forge | (main, Dec 5 2024, 14:06:23) [MSC v.1942 64 bit (AMD64)]
Qt: 5.15.2
PyQt5: 5.15.11
NumPy: 1.24.0
SciPy: 1.15.0
Dask: 2024.12.1
VisPy: 0.14.3
magicgui: 0.10.0
superqt: 0.7.1
in-n-out: 0.2.1
app-model: 0.3.1
psygnal: 0.11.1
npe2: 0.7.7
pydantic: 2.10.4
OpenGL:
Screens:
Optional:
Settings path:
Plugins:
💡 Additional Context
No response
The text was updated successfully, but these errors were encountered: