Commit 03aef74 1 parent 768646d commit 03aef74 Copy full SHA for 03aef74
File tree 2 files changed +7
-5
lines changed
backend/src/common/services/image
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change
1
+ const PREVIEW_WIDTH = 1920 ;
2
+ const PREVIEW_HEIGHT = 1080 ;
3
+
4
+ export { PREVIEW_HEIGHT , PREVIEW_WIDTH } ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import sharp from 'sharp';
2
2
3
3
import { type FileService } from '~/common/services/file/file.service.js' ;
4
4
5
+ import { PREVIEW_HEIGHT , PREVIEW_WIDTH } from './constants/constants.js' ;
5
6
import { type ImageApi } from './image-base.js' ;
6
7
import { type Composition } from './types/types.js' ;
7
8
@@ -54,18 +55,15 @@ class ImageService {
54
55
avatar : Buffer ,
55
56
background : Buffer ,
56
57
) : Promise < Buffer > {
57
- const finalWidth = 1920 ;
58
- const finalHeight = 1080 ;
59
-
60
58
const resizedBackground = await sharp ( background )
61
- . resize ( finalWidth , finalHeight , {
59
+ . resize ( PREVIEW_WIDTH , PREVIEW_HEIGHT , {
62
60
fit : 'cover' ,
63
61
position : 'center' ,
64
62
} )
65
63
. toBuffer ( ) ;
66
64
67
65
const resizedAvatar = await sharp ( avatar )
68
- . resize ( finalWidth , finalHeight , {
66
+ . resize ( PREVIEW_WIDTH , PREVIEW_HEIGHT , {
69
67
fit : 'inside' ,
70
68
position : 'bottom' ,
71
69
} )
You can’t perform that action at this time.
0 commit comments