diff --git a/invokeai/app/api/routers/images.py b/invokeai/app/api/routers/images.py index a0428e772e..3da94df7f4 100644 --- a/invokeai/app/api/routers/images.py +++ b/invokeai/app/api/routers/images.py @@ -19,6 +19,9 @@ from ..dependencies import ApiDependencies images_router = APIRouter(prefix="/v1/images", tags=["images"]) +# images are immutable; set a high max-age +IMAGE_MAX_AGE = 31536000 + @images_router.post( "/", @@ -155,12 +158,14 @@ async def get_image_full( if not ApiDependencies.invoker.services.images.validate_path(path): raise HTTPException(status_code=404) - return FileResponse( + response = FileResponse( path, media_type="image/png", filename=image_name, content_disposition_type="inline", ) + response.headers["Cache-Control"] = f"max-age={IMAGE_MAX_AGE}" + return response except Exception as e: raise HTTPException(status_code=404) @@ -189,9 +194,11 @@ async def get_image_thumbnail( if not ApiDependencies.invoker.services.images.validate_path(path): raise HTTPException(status_code=404) - return FileResponse( + response = FileResponse( path, media_type="image/webp", content_disposition_type="inline" ) + response.headers["Cache-Control"] = f"max-age={IMAGE_MAX_AGE}" + return response except Exception as e: raise HTTPException(status_code=404) diff --git a/invokeai/app/invocations/latent.py b/invokeai/app/invocations/latent.py index da99afc50f..b3f95f3658 100644 --- a/invokeai/app/invocations/latent.py +++ b/invokeai/app/invocations/latent.py @@ -519,9 +519,9 @@ class ResizeLatentsInvocation(BaseInvocation): # Inputs latents: Optional[LatentsField] = Field( description="The latents to resize") - width: int = Field( + width: Union[int, None] = Field(default=512, ge=64, multiple_of=8, description="The width to resize to (px)") - height: int = Field( + height: Union[int, None] = Field(default=512, ge=64, multiple_of=8, description="The height to resize to (px)") mode: LATENTS_INTERPOLATION_MODE = Field( default="bilinear", description="The interpolation mode")