[Fix] #606 - 이미지 압축 함수 로직 수정 #607
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
⭐️Issue
🌟Motivation
compressImage로직을 수정했습니다.🌟Key Changes
AS-IS
기존 코드는 이미지 업로드 시 최대 이미지 용량을 0.25MB 이하로 제한하고 있으며, 이를 만족하지 못할 경우 빈 데이터를 반환하도록 처리하고 있습니다.
피드 수정 시, 이미 업로드된 이미지를 다시 불러오게 되는데, 이때 UIImage로 디코딩된 후 다시 압축을 시도하면 원본보다 압축 효율이 떨어져 용량이 다시 커질 수 있습니다. 따라서 압축된 이미지가 다시 0.25MB를 초과하게 되면서, 빈 데이터가 반환되고 서버에는 유효하지 않은 이미지가 전달되어 500 에러가 발생했습니다.
TO-BE
에러가 발생하지 않도록, 압축된 이미지가 0.25MB보다 크게 되더라도 가능한 가장 작게 압축된 데이터를 반환하여 서버 500 에러 방지하도록 했습니다.
🌟Simulation
잘 작동합니다.
🌟To Reviewer
피드 수정을 반복하면 이미지 압축이 반복적으로 진행되어 점차 이미지 화질이 저하가 발생합니다.. 흠 최대한 scale은 건들지 않고 quality만 줄여 이미지 사이즈를 줄여보고자 하는데 쉽지 않네여 ㅠ
🌟Reference