-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: 이미지 압축하는 기능 custom hook으로 구현 * feat: 지도, 핀 등에 이미지 추가할 시 이미지 압축 기능 추가 * refactor: NewTopic, NewPin 텍스트 수정 * refactor: 이미지 리사이징 최대 크기 변경 * refactor: 지도 추가 페이지에서 이미지와 파일 추가 버튼 사이에 space 추가
- Loading branch information
Showing
4 changed files
with
64 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import imageCompression from 'browser-image-compression'; | ||
|
||
const useCompressImage = () => { | ||
const compressImage = async (file: File) => { | ||
const resizingBlob = await imageCompression(file, { | ||
maxSizeMB: 1, | ||
maxWidthOrHeight: 750, | ||
useWebWorker: true, | ||
}); | ||
const resizingFile = new File([resizingBlob], file.name, { | ||
type: file.type, | ||
}); | ||
return resizingFile; | ||
}; | ||
|
||
const compressImageList = async (files: FileList) => { | ||
const compressedImageList: File[] = []; | ||
|
||
for (const file of files) { | ||
const compressedImage = await compressImage(file); | ||
compressedImageList.push(compressedImage); | ||
} | ||
|
||
return compressedImageList; | ||
}; | ||
|
||
return { compressImage, compressImageList }; | ||
}; | ||
|
||
export default useCompressImage; |
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