Skip to content

Commit 259b827

Browse files
authored
desklet-photoframe: change image size to guarantee keeping the ratio (#12717)
* desklet-photoframe: change image size to guarantee keeping the aspect ratio * Adjust code to match codestyle of codebase
1 parent 6646761 commit 259b827

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

files/usr/share/cinnamon/desklets/[email protected]/desklet.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,9 @@ class CinnamonPhotoFrameDesklet extends Desklet.Desklet {
153153
image.disconnect(image._notif_id);
154154

155155
let height, width;
156-
let imageRatio = image.width / image.height;
157-
let frameRatio = this.width / this.height;
158-
159-
if (imageRatio > frameRatio) {
160-
width = this.width;
161-
height = this.width / imageRatio;
162-
} else {
163-
height = this.height;
164-
width = this.height * imageRatio;
165-
}
166-
156+
let ratio = Math.min(this.width / image.width, this.height / image.height);
157+
width = ratio * image.width;
158+
height = ratio * image.height;
167159
image.set_size(width, height);
168160
}
169161

0 commit comments

Comments
 (0)