add new calculateRoomLogoParams method to FilesStore

This commit is contained in:
mushka 2022-08-25 04:59:39 +03:00
parent 2b936a8879
commit a93b2f3142

View File

@ -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);
}