-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
게시글 작성 시 이미지 파일을 보낼 때 webp 로 압축하여 성능 개선 (#614)
- Loading branch information
1 parent
7c15999
commit a68c06b
Showing
4 changed files
with
47 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import imageCompression from 'browser-image-compression'; | ||
|
||
export const convertImageToWebP = async (imageFile: File) => { | ||
const compressedBlob = await imageCompression(imageFile, { | ||
maxWidthOrHeight: 1280, | ||
initialQuality: 0.5, | ||
fileType: 'image/webp', | ||
}); | ||
|
||
const outputWebpFile = new File([compressedBlob], `${Date.now().toString()}.webp`); | ||
|
||
const dataTransfer = new DataTransfer(); | ||
|
||
dataTransfer.items.add(outputWebpFile); | ||
|
||
return dataTransfer.files; | ||
}; |