add new calculateRoomLogoParams method to FilesStore
This commit is contained in:
parent
2b936a8879
commit
a93b2f3142
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user