jimp-test
This commit is contained in:
parent
63f12021e4
commit
b6a2334fb8
@ -35,9 +35,11 @@ const cropImage = async (Key, width, height, left, top) => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
console.log(Body)
|
||||||
|
|
||||||
const image = await Jimp.read(Body)
|
const image = await Jimp.read(Body)
|
||||||
image.autocrop({ tolerance: 0.0002, leaveBorder: 10 })
|
image.autocrop({ tolerance: 0.0002, leaveBorder: 10 })
|
||||||
const editedBuffer = await image.getBufferAsync(Jimp.MIME_PNG)
|
const editedBuffer = await image.getBuffer('image/png')
|
||||||
|
|
||||||
return editedBuffer
|
return editedBuffer
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ const cropImage = async (Key, width, height, left, top) => {
|
|||||||
// processedImage = await image.toBuffer()
|
// processedImage = await image.toBuffer()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let processedImage
|
//let processedImage
|
||||||
// if (!checkResult) {
|
// if (!checkResult) {
|
||||||
// processedImage = await sharp(imageBuffer).toBuffer()
|
// processedImage = await sharp(imageBuffer).toBuffer()
|
||||||
// } else {
|
// } else {
|
||||||
@ -68,7 +70,7 @@ const cropImage = async (Key, width, height, left, top) => {
|
|||||||
// .png()
|
// .png()
|
||||||
// .toBuffer()
|
// .toBuffer()
|
||||||
// }
|
// }
|
||||||
return processedImage
|
// return processedImage
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error processing image:', error)
|
console.error('Error processing image:', error)
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupSta
|
|||||||
import { useImgLoader } from '@/hooks/floorPlan/useImgLoader'
|
import { useImgLoader } from '@/hooks/floorPlan/useImgLoader'
|
||||||
import { usePlan } from '@/hooks/usePlan'
|
import { usePlan } from '@/hooks/usePlan'
|
||||||
import { QcastContext } from '@/app/QcastProvider'
|
import { QcastContext } from '@/app/QcastProvider'
|
||||||
|
import { fabric } from 'fabric'
|
||||||
|
|
||||||
const ALLOCATION_TYPE = {
|
const ALLOCATION_TYPE = {
|
||||||
AUTO: 'auto',
|
AUTO: 'auto',
|
||||||
@ -102,10 +103,12 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
// 50%로 만든 다
|
||||||
const handleZoomClear = () => {
|
const handleZoomClear = () => {
|
||||||
setCanvasZoom(100)
|
// setCanvasZoom(100)
|
||||||
canvas.set({ zoom: 1 })
|
const x = canvas.width / 2
|
||||||
canvas.viewportTransform = [1, 0, 0, 1, 0, 0]
|
const y = canvas.height / 2
|
||||||
|
canvas.zoomToPoint(new fabric.Point(x, y), 0.5)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user