mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-23 16:24:06 +00:00
Support previewing animated image uploads (#3479)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -10,3 +10,20 @@ export const is_all_same_aspect_ratio = (imgs: HTMLImageElement[]): boolean => {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export const fitDimensionsToNodeWidth = (
|
||||
width: number,
|
||||
height: number,
|
||||
nodeWidth: number,
|
||||
minHeight: number = 64
|
||||
): { minHeight: number; minWidth: number } => {
|
||||
const intrinsicAspectRatio = width / height
|
||||
if (!intrinsicAspectRatio || isNaN(intrinsicAspectRatio))
|
||||
return { minHeight: 0, minWidth: 0 }
|
||||
|
||||
// Set min. height s.t. image spans node's x-axis while maintaining aspect ratio
|
||||
const minWidth = nodeWidth
|
||||
const calculatedHeight = Math.max(minWidth / intrinsicAspectRatio, minHeight)
|
||||
|
||||
return { minHeight: calculatedHeight, minWidth }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user