feat: square crop preset

This commit is contained in:
httpjamesm 2023-10-14 23:01:20 -04:00
parent b9b8cfa84b
commit 7fdbaa9e2d
No known key found for this signature in database

View file

@ -70,7 +70,16 @@ const ImageEditorOverlay = (props: IProps) => {
const height = img.height * scale; const height = img.height * scale;
canvasRef.current.width = width; canvasRef.current.width = width;
canvasRef.current.height = height; canvasRef.current.height = height;
canvasRef.current.style.transition = 'width 0.5s, height 0.5s';
canvasRef.current.style.width = `${width}px`;
canvasRef.current.style.height = `${height}px`;
// Apply CSS transition to animate the resizing
ctx?.drawImage(img, 0, 0, width, height); ctx?.drawImage(img, 0, 0, width, height);
setTimeout(() => {
canvasRef.current.style.transition = 'none';
}, 500); // Adjust the time to match your animation duration
}; };
}; };
@ -204,6 +213,14 @@ const ImageEditorOverlay = (props: IProps) => {
}} }}
label={'Original'} label={'Original'}
/> />
<EnteMenuItem
disabled={cropLoading}
startIcon={<CropSquareIcon />}
onClick={() => {
cropCanvas(1, 1);
}}
label={'Square (1:1)'}
/>
</MenuItemGroup> </MenuItemGroup>
<MenuItemGroup <MenuItemGroup
style={{ style={{