Files
AnyImage/src/anyimage/menu.py
nan c97b4a3e41 Add image selection refinement functionality with BEN2 integration
- Implemented viewport.py for handling 3D view projections, gestures, and overlay drawing.
- Created refine_image_selection.py to manage the refinement of gesture masks and output image bounds.
- Added selection module with refine_selection.py to process and crop images based on alpha channel visibility.
- Introduced __init__.py for selection module to expose refine_selection function.
2026-08-31 22:10:05 +08:00

69 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import bpy
from .common.image import is_image_empty
from .operators.upscale import upscale_output_size
class AnyImageImageMenu(bpy.types.Menu):
bl_idname = "ANYIMAGE_MT_image_context"
bl_label = "AnyImage"
def draw(self, context):
from .properties import ai_setup_label, ai_status
layout = self.layout
layout.operator_context = "INVOKE_DEFAULT"
layout.operator(
"anyimage.convert_to_plane",
text="Convert to Plane",
icon="MESH_PLANE",
)
layout.operator(
"anyimage.convert_to_depth_plane",
text="Convert to Depth Plane",
icon="MOD_DISPLACE",
)
layout.separator()
layout.operator(
"anyimage.remove_image_background",
text="Remove Background",
icon="IMAGE_ALPHA",
)
layout.operator(
"anyimage.upscale_image",
text=upscale_menu_label(context),
icon="FULLSCREEN_ENTER",
)
layout.separator()
status = ai_status()
if status["ready"]:
layout.operator(
"anyimage.open_ai_environment_settings",
text="AI Environment Settings",
icon="PREFERENCES",
)
else:
layout.operator(
"anyimage.setup_ai_environment",
text=ai_setup_label(status),
icon="IMPORT",
)
def upscale_menu_label(context):
source_object = getattr(context, "object", None)
if not is_image_empty(source_object):
return "Upscale"
output_size = upscale_output_size(source_object.data)
if output_size is None:
return "Upscale"
width, height = output_size
return f"Upscale ({width} × {height})"
def draw_image_context_menu(self, context):
if not is_image_empty(context.object):
return
self.layout.menu(AnyImageImageMenu.bl_idname, text="AnyImage", icon="PLUGIN")
self.layout.separator()