diff --git a/packages/client/src/store/FilesStore.js b/packages/client/src/store/FilesStore.js index 8d100faabc..79997ac7ee 100644 --- a/packages/client/src/store/FilesStore.js +++ b/packages/client/src/store/FilesStore.js @@ -1592,6 +1592,29 @@ class FilesStore { return api.rooms.removeTagsFromRoom(id, tagArray); } + calculateRoomLogoParams(img, x, y, zoom) { + let imgWidth, imgHeight, dimensions; + if (img.width > img.height) { + imgWidth = Math.min(1280, img.width); + imgHeight = Math.round(img.height / (img.width / imgWidth)); + dimensions = Math.round(imgHeight / zoom); + } else { + imgHeight = Math.min(1280, img.height); + imgWidth = Math.round(img.width / (img.height / imgHeight)); + dimensions = Math.round(imgWidth / zoom); + } + + const croppedX = Math.round(x * imgWidth - dimensions / 2); + const croppedY = Math.round(y * imgHeight - dimensions / 2); + + return { + x: croppedX, + y: croppedY, + width: dimensions, + height: dimensions, + }; + } + uploadRoomLogo(formData) { return api.rooms.uploadRoomLogo(formData); }