📌fix: 이미지 크롭 좌표 계산식 개선
This commit is contained in:
parent
6c94fdf1a1
commit
259ac8ad3d
@ -28,8 +28,8 @@ export function useImgLoader() {
|
||||
const minX = objects.reduce((acc, cur) => (cur.left < acc ? cur.left : acc), objects[0].left)
|
||||
const minY = objects.reduce((acc, cur) => (cur.top < acc ? cur.top : acc), objects[0].top)
|
||||
|
||||
const maxX = objects.reduce((acc, cur) => (cur.left + cur.width > acc ? cur.left + cur.width : acc), 0)
|
||||
const maxY = objects.reduce((acc, cur) => (cur.top + cur.height > acc ? cur.top + cur.height : acc), 0)
|
||||
const maxX = objects.reduce((acc, cur) => (cur.left + cur.width > acc ? cur.left : acc), 0)
|
||||
const maxY = objects.reduce((acc, cur) => (cur.top + cur.height > acc ? cur.top : acc), 0)
|
||||
return [
|
||||
{ x: minX - margin, y: minY - margin },
|
||||
{ x: maxX + margin, y: maxY + margin },
|
||||
@ -70,8 +70,8 @@ export function useImgLoader() {
|
||||
// formData.append('coordinates', getImageCoordinates())
|
||||
const positionObj = getImageCoordinates()
|
||||
console.log('🚀 ~ handleCanvasToPng ~ positionObj:', positionObj)
|
||||
formData.append('width', Math.round(positionObj[1].x - positionObj[0].x - 350))
|
||||
formData.append('height', Math.round(positionObj[1].y - positionObj[0].y - 100))
|
||||
formData.append('width', Math.round(positionObj[1].x - positionObj[0].x + 100))
|
||||
formData.append('height', Math.round(positionObj[1].y - positionObj[0].y + 100))
|
||||
formData.append('left', Math.round(positionObj[0].x))
|
||||
formData.append('top', Math.round(positionObj[0].y))
|
||||
console.log('🚀 ~ handleCanvasToPng ~ formData:', formData)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user