-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/#114 image compression (+webp) #208
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이미지 크기와 시간이 엄청 줄어들었네?! 신기하다!!!!!👀🌟
수고하셨숩니다ㅎㅎ😚😚
관련해소 궁금한게 있는데요!
- 앞으로 작업할 때, 저희가 webp 파일로 변환해서 쓰는 걸까요? 아니면 디자인에서 그렇게 넘겨주는 걸까요?-?
- png 파일을 따로 모아두신 이유가 궁금합니당!
src/asset/image/index.tsx
Outdated
export { default as ImgBanner3 } from "./banner_3.webp"; | ||
export { default as ImgCategoryBanner } from "./categoryBanner.webp"; | ||
export { default as ImgDefaultBigProfile } from "./defaultBigProfile.webp"; | ||
export { default as ImgDefaultProfile } from "./defaultProfile.webp"; | ||
export { default as ImgPiickleLoading } from "./piickleLoading.gif"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.gif
는 .webp
로 변환하지 않은 이유가 있을까요?-? 마찬가지로 용량이 줄어든다고 알고 있어서요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉 그것도 되는구나!! 변경해놓을게요
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compressorjs
라이브러리 이해하다가 리뷰가 늦었네요😋 (답변 속도 실화냐고)
파일 업로드 시에 이미지 용량을 줄일 때 사용하눈거군여!!
코드리뷰하면서 오늘 많은 것을 배워갑니다,,✨ 수고해쒀어어어어어><
@@ -25,7 +25,7 @@ export default function Banner() { | |||
<St.BannerSlider> | |||
<Slider {...settings}> | |||
{bannerImage.map((img, index) => ( | |||
<St.ImageWrapper key={index} src={img.src} alt={img.alt} /> | |||
<St.ImageWrapper key={index} src={img.src} alt={img.alt} loading="lazy" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loading="lazy"
처음 알게 되었어요😲 좋은 정보 감사합니다:D
const compressedSelectedImg = await compressImage(selectedImg, { | ||
maxWidth: MAX_IMAGE_SIZE, | ||
maxHeight: MAX_IMAGE_SIZE, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요로코롬 사용하눈 거구나👀👀 므싯다요😎😎😎😎
const { setImage } = props; | ||
const [imgUrl, setImgUrl] = useState<string>(""); | ||
const { setProfileImage } = props; | ||
const [previewImgUrl, setPreviewImgUrl] = useState(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<string>
요거 있는거랑 없는거랑 상관업숴?-?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"" 로 string인게 이미 추론되어서, 직접 명시할 필요 없어!!
} | ||
|
||
const MAX_IMAGE_SIZE = 80 * 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최대치가 *2
인 이유가 있을까요?!?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
80으로 직접 명시를 해도 좋은데, 레티나 디스플레이 대응 이슈로 인해 2배 정도로 지정하면 좋다고 알아요!!!~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하 구렇구나😆😆
new Compressor(file, { | ||
maxWidth: option?.maxWidth, | ||
maxHeight: option?.maxHeight, | ||
quality: option?.quality ?? 0.6, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
요거 무엇인가요?_? 처음 봐써요!👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined, null 일 경우에만 ??
다음의 값을 반환해줘!
이미지 최적화를 위한 추가 작업 -> #219 |
📌 내용
banner1, category banner 같은 경우에, 이미지의 파일이 커서 png 파일을 압축하였어요.
png -> webp 파일로 변경하였어요.
picture
/source
태그를 추가하여 jpg 파일을 대비하지 않았어요. 필요하다고 판단되면 진행하면 좋을 것 같아요.img 태그에 loading="lazy" 속성을 추가하면, 보여지지 않는 이미지는 나중에 로드하여 불필요한 네트워크 통신을 줄일 수 있어요
📌 내가 알게 된 부분
compressorjs
라이브러리 적용했어요util/imageCompressor.ts
로 비동기 처리 추상화하여 사용합니다!📸 스크린샷
1. 적용 전
2. 적용 후