Refactor node image upload and preview (#2580)

Co-authored-by: huchenlei <huchenlei@proton.me>
This commit is contained in:
bymyself
2025-02-16 08:09:02 -07:00
committed by GitHub
parent 317ea8b932
commit df11c99393
9 changed files with 403 additions and 186 deletions

12
src/utils/imageUtil.ts Normal file
View File

@@ -0,0 +1,12 @@
export const is_all_same_aspect_ratio = (imgs: HTMLImageElement[]): boolean => {
if (!imgs.length || imgs.length === 1) return true
const ratio = imgs[0].naturalWidth / imgs[0].naturalHeight
for (let i = 1; i < imgs.length; i++) {
const this_ratio = imgs[i].naturalWidth / imgs[i].naturalHeight
if (ratio != this_ratio) return false
}
return true
}