jimp-test

This commit is contained in:
hyojun.choi 2025-06-05 17:25:45 +09:00
parent 63f12021e4
commit b6a2334fb8
2 changed files with 11 additions and 6 deletions

View File

@ -35,9 +35,11 @@ const cropImage = async (Key, width, height, left, top) => {
}),
)
console.log(Body)
const image = await Jimp.read(Body)
image.autocrop({ tolerance: 0.0002, leaveBorder: 10 })
const editedBuffer = await image.getBufferAsync(Jimp.MIME_PNG)
const editedBuffer = await image.getBuffer('image/png')
return editedBuffer
@ -54,7 +56,7 @@ const cropImage = async (Key, width, height, left, top) => {
// processedImage = await image.toBuffer()
// }
let processedImage
//let processedImage
// if (!checkResult) {
// processedImage = await sharp(imageBuffer).toBuffer()
// } else {
@ -68,7 +70,7 @@ const cropImage = async (Key, width, height, left, top) => {
// .png()
// .toBuffer()
// }
return processedImage
// return processedImage
} catch (error) {
console.error('Error processing image:', error)
throw error

View File

@ -25,6 +25,7 @@ import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupSta
import { useImgLoader } from '@/hooks/floorPlan/useImgLoader'
import { usePlan } from '@/hooks/usePlan'
import { QcastContext } from '@/app/QcastProvider'
import { fabric } from 'fabric'
const ALLOCATION_TYPE = {
AUTO: 'auto',
@ -102,10 +103,12 @@ export default function CircuitTrestleSetting({ id }) {
}
}, [])
// 50%
const handleZoomClear = () => {
setCanvasZoom(100)
canvas.set({ zoom: 1 })
canvas.viewportTransform = [1, 0, 0, 1, 0, 0]
// setCanvasZoom(100)
const x = canvas.width / 2
const y = canvas.height / 2
canvas.zoomToPoint(new fabric.Point(x, y), 0.5)
canvas.renderAll()
}