diff --git a/lama_cleaner/app/src/Editor.tsx b/lama_cleaner/app/src/Editor.tsx index fa11911..ce937eb 100644 --- a/lama_cleaner/app/src/Editor.tsx +++ b/lama_cleaner/app/src/Editor.tsx @@ -402,9 +402,10 @@ export default function Editor(props: EditorProps) { ].join(' ')} > void } export default function SizeSelector(props: SizeSelectorProps) { - const { value, originalSize, onChange } = props + const { value, originalHeight, originalWidth, onChange } = props + + const getSizeShowName = (size: string) => { + if (size === 'Original') { + return `${originalWidth}x${originalHeight}(${size})` + } + const length: number = parseInt(size, 10) + const longSide: number = + originalWidth > originalHeight ? originalWidth : originalHeight + const scale = length / longSide + + if (originalWidth > originalHeight) { + const newHeight = Math.ceil(scale * originalHeight) + return `${size}x${newHeight}` + } + const newWidth = Math.ceil(scale * originalWidth) + return `${newWidth}x${size}` + } return ( - - Resize - {sizes.map(size => ( - - {({ checked }) => ( -
-
-
- {size[0] === 'Original' ? ( - {`${size[1]}(${originalSize})`} - ) : ( - {size[1]} +
+ +
+ + {sizes.map((size, _) => ( + + `${active ? 'bg-black bg-opacity-10' : 'text-gray-900'} + cursor-default select-none relative py-2 pl-10 pr-4` + } + value={size} + > + {({ selected, active }) => ( + <> + + {getSizeShowName(size)} + + {selected ? ( + + + ) : null} + )} -
-
- )} - - ))} - + + ))} + + + {getSizeShowName(value)} + + + +
+ +
) }