feat: Add visual crop preview widget for ImageCrop node - widget ImageCrop (#7825)

## Summary

Another implementation for image crop node, alternative for
https://github.com/Comfy-Org/ComfyUI_frontend/pull/7014
As discussed with @christian-byrne and @DrJKL we could have single
widget - IMAGECROP with 4 ints and UI preview.

However, this solution requires changing the definition of image crop
node in BE (sent
[here](https://github.com/comfyanonymous/ComfyUI/pull/11594)), which
will break the exsiting workflow, also it would not allow connect
separate int node as input, I am not sure it is a good idea.

So I keep two PRs openned for references

## Screenshots


https://github.com/user-attachments/assets/fde6938c-4395-48f6-ac05-6282c5eb8157

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7825-feat-Add-visual-crop-preview-widget-for-ImageCrop-node-widget-ImageCrop-2dc6d73d3650812bb8a2cdff4615032b)
by [Unito](https://www.unito.io)
This commit is contained in:
Terry Jia
2026-01-17 17:09:16 -05:00
committed by GitHub
parent de2e37ec8e
commit be8916b4ce
17 changed files with 932 additions and 63 deletions

View File

@@ -64,6 +64,21 @@ const zImageCompareInputSpec = zBaseInputOptions.extend({
options: z.record(z.unknown()).optional()
})
const zBoundingBoxInputSpec = zBaseInputOptions.extend({
type: z.literal('BOUNDINGBOX'),
name: z.string(),
isOptional: z.boolean().optional(),
component: z.enum(['ImageCrop']).optional(),
default: z
.object({
x: z.number(),
y: z.number(),
width: z.number(),
height: z.number()
})
.optional()
})
const zMarkdownInputSpec = zBaseInputOptions.extend({
type: z.literal('MARKDOWN'),
name: z.string(),
@@ -126,6 +141,7 @@ const zInputSpec = z.union([
zColorInputSpec,
zImageInputSpec,
zImageCompareInputSpec,
zBoundingBoxInputSpec,
zMarkdownInputSpec,
zChartInputSpec,
zGalleriaInputSpec,
@@ -169,6 +185,7 @@ type StringInputSpec = z.infer<typeof zStringInputSpec>
export type ComboInputSpec = z.infer<typeof zComboInputSpec>
export type ColorInputSpec = z.infer<typeof zColorInputSpec>
export type ImageCompareInputSpec = z.infer<typeof zImageCompareInputSpec>
export type BoundingBoxInputSpec = z.infer<typeof zBoundingBoxInputSpec>
export type ChartInputSpec = z.infer<typeof zChartInputSpec>
export type GalleriaInputSpec = z.infer<typeof zGalleriaInputSpec>
export type TextareaInputSpec = z.infer<typeof zTextareaInputSpec>