{"library":"napari-svg","title":"Napari SVG Exporter","description":"napari-svg is a plugin for the napari viewer that enables exporting layers as SVG (Scalable Vector Graphics) files. It integrates directly into napari's file saving mechanism, allowing users to save their viewer's contents as vector graphics. The current version is 0.2.1, and being a napari plugin, its release cadence often aligns with napari's ecosystem updates, offering stability for its core functionality.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install napari-svg"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import napari\nimport numpy as np\nimport os\n\n# Create a napari viewer\nviewer = napari.Viewer()\n\n# Add some sample data to visualize\nviewer.add_image(np.random.rand(100, 100), name='random_image')\nviewer.add_labels(np.zeros((100, 100), dtype=int), name='empty_labels')\nviewer.add_points(np.random.rand(10, 2) * 100, name='random_points')\nviewer.add_shapes(np.array([[20, 20], [20, 80], [80, 80], [80, 20]]), name='square_shape')\n\nprint(\"Napari viewer is running with sample data.\")\nprint(\"To save as SVG: In the napari GUI, go to 'File > Save Selected Layers As...' or 'File > Save All Layers As...'.\")\nprint(\"Then, select '.svg' as the file type and choose a filename. napari-svg will handle the export.\")\n\n# Example of attempting a programmatic save (requires napari-svg to be registered)\n# Note: GUI method is often more robust for plugins that register writers.\noutput_filename = 'napari_output.svg'\ntry:\n    # This attempts to use napari's internal writer selection based on extension\n    # The napari-svg plugin should be automatically detected if installed.\n    viewer.save(output_filename, selected=False) # Saves all layers\n    print(f\"Attempted programmatic save to '{output_filename}'. Check if file exists.\")\nexcept Exception as e:\n    print(f\"Programmatic save failed: {e}. The GUI method is generally more reliable for plugins.\")\n\n# Clean up the created file for demonstration purposes\n# if os.path.exists(output_filename):\n#     os.remove(output_filename)\n#     print(f\"Cleaned up '{output_filename}'.\")\n\nnapari.run()","lang":"python","description":"This quickstart demonstrates how to launch a napari viewer, add some sample layers, and then explains how to use the napari-svg plugin via the napari GUI's 'Save As...' dialog. The plugin automatically registers itself with napari's file writer system upon installation. While programmatic saving is also possible through `viewer.save()`, the GUI method ensures the plugin's writer is correctly invoked and provides direct user control over export options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}