From 896b77cf56da761667f8b617eb2e030c12a35c38 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:44:55 +1000 Subject: [PATCH] feat(api,db): allow creating an image with a board_id --- invokeai/app/api/routers/images.py | 4 ++++ invokeai/app/services/images.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/invokeai/app/api/routers/images.py b/invokeai/app/api/routers/images.py index 01e7dd2c26..2bab7d479a 100644 --- a/invokeai/app/api/routers/images.py +++ b/invokeai/app/api/routers/images.py @@ -40,6 +40,9 @@ async def upload_image( response: Response, image_category: ImageCategory = Query(description="The category of the image"), is_intermediate: bool = Query(description="Whether this is an intermediate image"), + board_id: Optional[str] = Query( + default=None, description="The board to add this image to, if any" + ), session_id: Optional[str] = Query( default=None, description="The session ID associated with this upload, if any" ), @@ -62,6 +65,7 @@ async def upload_image( image_origin=ResourceOrigin.EXTERNAL, image_category=image_category, session_id=session_id, + board_id=board_id, is_intermediate=is_intermediate, ) diff --git a/invokeai/app/services/images.py b/invokeai/app/services/images.py index 6fdb6237f8..dc1b18babe 100644 --- a/invokeai/app/services/images.py +++ b/invokeai/app/services/images.py @@ -52,6 +52,7 @@ class ImageServiceABC(ABC): image_category: ImageCategory, node_id: Optional[str] = None, session_id: Optional[str] = None, + board_id: Optional[str] = None, is_intermediate: bool = False, metadata: Optional[dict] = None, ) -> ImageDTO: @@ -174,6 +175,7 @@ class ImageService(ImageServiceABC): image_category: ImageCategory, node_id: Optional[str] = None, session_id: Optional[str] = None, + board_id: Optional[str] = None, is_intermediate: bool = False, metadata: Optional[dict] = None, ) -> ImageDTO: @@ -215,6 +217,11 @@ class ImageService(ImageServiceABC): session_id=session_id, ) + if board_id is not None: + self._services.board_image_records.add_image_to_board( + board_id=board_id, image_name=image_name + ) + self._services.image_files.save( image_name=image_name, image=image, metadata=metadata, graph=graph )