-
Notifications
You must be signed in to change notification settings - Fork 189
Description
First, I'd like to thank the maintainers for creating and maintaining the excellent ComfyUI LayerStyle node - it's an incredibly valuable tool for advanced image compositing and blending operations in ComfyUI workflows! Your work on providing professional-grade layer effects is greatly appreciated.
Description
Users with NumPy 2.0+ installations encounter an AttributeError: np.asfarraywas removed in the NumPy 2.0 release. Usenp.asarray with a proper dtype instead. when trying to use any LayerStyle blending operations. This prevents all image blending functionality from working with modern NumPy versions.
Current Behavior
- LayerStyle nodes work fine with NumPy 1.x installations
- Throws AttributeError when NumPy 2.0+ is installed
- Error occurs during image preparation in blending operations
Steps to Reproduce
- Install NumPy 2.0 or later
- Add any LayerStyle blending node to ComfyUI workflow
- Connect image inputs and attempt to execute
- Error occurs during blending operation
Error Details
AttributeError: `np.asfarray` was removed in the NumPy 2.0 release. Use `np.asarray` with a proper dtype instead.
File "ComfyUI\custom_nodes\comfyui_layerstyle\py\image_blend_v2.py", line 74, in image_blend_v2
_comp = chop_image_v2(_canvas, _layer, blend_mode, opacity)
File "ComfyUI\custom_nodes\comfyui_layerstyle\py\imagefunc.py", line 368, in chop_image_v2
backdrop_prepped = np.asfarray(background_image.convert('RGBA'))
Root Cause
The issue occurs because:
np.asfarraywas deprecated and removed in NumPy 2.0- Code uses outdated NumPy API incompatible with NumPy 2.0+
- Modern NumPy installations break all LayerStyle functionality
Environment
- ComfyUI with NumPy 2.0+
- ComfyUI LayerStyle custom nodes
- Modern Python environments with updated NumPy
Proposed Solution
Replace deprecated np.asfarray with np.asarray and explicit dtype:
Changes needed in py/imagefunc.py around lines 368-369:
# Before:
backdrop_prepped = np.asfarray(background_image.convert('RGBA'))
source_prepped = np.asfarray(layer_image.convert('RGBA'))
# After:
backdrop_prepped = np.asarray(background_image.convert('RGBA'), dtype=np.float64)
source_prepped = np.asarray(layer_image.convert('RGBA'), dtype=np.float64)Why This Matters
- Critical compatibility: Enables LayerStyle nodes with modern NumPy versions
- User experience: Eliminates crashes for users with updated environments
- Future-proofing: Ensures compatibility with current and future NumPy releases
- Widespread impact: Affects all LayerStyle users with NumPy 2.0+
Testing
- NumPy compatibility: Confirmed works with both NumPy 1.x and 2.x
- Output quality: Blending effects identical across NumPy versions
- Blend modes: All blend modes (multiply, screen, overlay, etc.) work correctly
- Performance: No degradation in processing speed
- Backward compatibility: Existing workflows unaffected
Impact
- Risk: Very low - direct API replacement with identical behavior
- Scope: Affects only numpy array creation, no functional changes
- Compatibility: Fully backward and forward compatible
This fix restores full functionality for users with modern NumPy installations while maintaining all existing behavior. Your continued work on ComfyUI LayerStyle is invaluable to the community - thank you for maintaining such a comprehensive and professional layer effects toolkit!