Skip to content

Commit 03aef74

Browse files
committedSep 25, 2024
OV-423: + constants
1 parent 768646d commit 03aef74

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const PREVIEW_WIDTH = 1920;
2+
const PREVIEW_HEIGHT = 1080;
3+
4+
export { PREVIEW_HEIGHT, PREVIEW_WIDTH };

‎backend/src/common/services/image/image.service.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import sharp from 'sharp';
22

33
import { type FileService } from '~/common/services/file/file.service.js';
44

5+
import { PREVIEW_HEIGHT, PREVIEW_WIDTH } from './constants/constants.js';
56
import { type ImageApi } from './image-base.js';
67
import { type Composition } from './types/types.js';
78

@@ -54,18 +55,15 @@ class ImageService {
5455
avatar: Buffer,
5556
background: Buffer,
5657
): Promise<Buffer> {
57-
const finalWidth = 1920;
58-
const finalHeight = 1080;
59-
6058
const resizedBackground = await sharp(background)
61-
.resize(finalWidth, finalHeight, {
59+
.resize(PREVIEW_WIDTH, PREVIEW_HEIGHT, {
6260
fit: 'cover',
6361
position: 'center',
6462
})
6563
.toBuffer();
6664

6765
const resizedAvatar = await sharp(avatar)
68-
.resize(finalWidth, finalHeight, {
66+
.resize(PREVIEW_WIDTH, PREVIEW_HEIGHT, {
6967
fit: 'inside',
7068
position: 'bottom',
7169
})

0 commit comments

Comments
 (0)