mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
fix(nodes): img_conv node should only allow conversion to modes that it can save
Because all our nodes output images in PNG format, any mode not supported by the PNG file format will result in an error when saving the image. The valid modes are thus limited now to L, RGB, RGBA, and I.
This commit is contained in:
@@ -11,7 +11,6 @@ from invokeai.app.invocations.baseinvocation import (
|
||||
Classification,
|
||||
invocation,
|
||||
)
|
||||
from invokeai.app.invocations.constants import IMAGE_MODES
|
||||
from invokeai.app.invocations.fields import (
|
||||
BoundingBoxField,
|
||||
ColorField,
|
||||
@@ -268,18 +267,21 @@ class ImageChannelInvocation(BaseInvocation, WithMetadata, WithBoard):
|
||||
return ImageOutput.build(image_dto)
|
||||
|
||||
|
||||
PNG_IMAGE_MODES = Literal["L", "RGB", "RGBA", "I"]
|
||||
|
||||
|
||||
@invocation(
|
||||
"img_conv",
|
||||
title="Convert Image Mode",
|
||||
tags=["image", "convert"],
|
||||
category="image",
|
||||
version="1.2.2",
|
||||
version="2.0.0",
|
||||
)
|
||||
class ImageConvertInvocation(BaseInvocation, WithMetadata, WithBoard):
|
||||
"""Converts an image to a different mode."""
|
||||
|
||||
image: ImageField = InputField(description="The image to convert")
|
||||
mode: IMAGE_MODES = InputField(default="L", description="The mode to convert to")
|
||||
mode: PNG_IMAGE_MODES = InputField(default="L", description="The mode to convert to")
|
||||
|
||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||
image = context.images.get_pil(self.image.image_name)
|
||||
|
||||
Reference in New Issue
Block a user