Skip to content

feat: 이미지 리사이징 로직 추가#426

Merged
dh2906 merged 15 commits intodevelopfrom
fix/reader-iis-bind
Mar 21, 2026
Merged

feat: 이미지 리사이징 로직 추가#426
dh2906 merged 15 commits intodevelopfrom
fix/reader-iis-bind

Conversation

@dh2906
Copy link
Contributor

@dh2906 dh2906 commented Mar 21, 2026

🔍 개요


🚀 주요 변경 내용

  • 이미지 리사이징 로직을 추가했습니다.

    • 가로는 최대 1800px 허용하며, 세로는 가로와 비율을 맞춥니다.
    • AWS 람다에서도 조회 시 이미지 리사이징이 적용되므로 크기는 최대한 보수적으로 잡았습니다.
  • JPEG 파일을 업로드할 시 이미지 리더에 바인딩 되지 않는 문제를 해결했습니다.


💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

@dh2906 dh2906 self-assigned this Mar 21, 2026
@dh2906 dh2906 added the 버그 정상적으로 동작하지 않는 문제 상황 관련 이슈입니다. label Mar 21, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

📝 Walkthrough

Walkthrough

이미지 변환 로직의 WebP 디코딩·리사이즈 및 타입/EXIF 처리 흐름이 변경되었고, 관련 단위·통합 테스트가 추가·확장되었으며, 프로젝트 전역에서 google-service-account.json을 무시하도록 .gitignore에 규칙이 추가되었습니다.

Changes

Cohort / File(s) Summary
설정 파일
.gitignore
모든 디렉터리 깊이에서 google-service-account.json 파일을 무시하도록 **/google-service-account.json 규칙 추가.
이미지 변환 로직
src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
WebP 전용 정규화 경로(normalizeWebp) 추가, ImageReader.setInput(iis) 명시적 호출, EXIF 적용 후 최대 업로드 너비 및 WebP 차수(최대 치수) 기준의 2단계 리사이즈 로직 도입, 호환 가능한 출력 BufferedImage 생성 로직 통합 및 리사이즈 관련 로깅 추가.
통합 테스트 (업로드)
src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
JPEG/PNG/WebP 업로드 케이스 확장 및 WebP 패스스루·리사이즈 결과 검증 추가, S3 PutObjectRequest의 contentType/키 확장자/업로드 바이트 일치성 검사 추가, createJpegBytes/createWebpBytes 헬퍼 추가, GoogleCredentials 모킹 추가.
단위 테스트 (이미지 변환)
src/test/java/gg/agit/konect/unit/upload/service/ImageConversionServiceTest.java
convertToWebP() 동작(리사이즈, WebP 변환, 알파 보존 등)을 검증하는 새로운 단위 테스트 클래스 추가 및 PNG/WebP 바이트 생성 헬퍼 추가.
테스트 네임스페이스
src/test/java/gg/agit/konect/unit/global/auth/web/AuthorizationInterceptorTest.java
테스트 파일의 package 선언을 gg.agit.konect.unit.authgg.agit.konect.unit.global.auth.web로 변경.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 픽셀 솜씨로 바람을 잘라,
바이트 춤추며 WebP로 가네.
테스트 도장 찍고 키는 .webp,
비밀파일은 무시하라, 깡총! 📸✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 이미지 리사이징 로직 추가라는 주요 변경 사항을 명확하게 요약하고 있으며, 변경 사항의 핵심을 정확하게 반영합니다.
Description check ✅ Passed Pull request description는 이미지 리사이징 로직 추가 및 JPEG 파일 업로드 바인딩 문제 해결에 관한 구체적인 내용을 포함하고 있으며, 변경 사항과 직접적으로 관련이 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reader-iis-bind

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.gitignore:
- Line 53: You've correctly added google-service-account.json to .gitignore;
update the ignore pattern to also match that filename in any subdirectory by
replacing or adding the glob pattern **/google-service-account.json in the
.gitignore so nested copies are ignored as well, and confirm no tracked
instances exist in the repo (use git status/ls-files) before committing the
change to avoid accidentally leaving a tracked secret.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 967793bc-4a9c-42d8-a5e3-6da5c2f9b56c

📥 Commits

Reviewing files that changed from the base of the PR and between 6195ed8 and 4fa9bfe.

📒 Files selected for processing (3)
  • .gitignore
  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
src/main/java/**/*.java

⚙️ CodeRabbit configuration file

src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.

  • 코멘트는 반드시 한국어로 작성한다.
  • 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
  • 각 코멘트 첫 줄에 심각도를 [LEVEL: high|medium|low] 형식으로 반드시 표기한다.
  • 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
  • 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
  • 가능하면 재현 조건 및 실패 시나리오도 포함한다.
  • 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
  • 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
  • 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
  • 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
  • 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.

Files:

  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java

@dh2906 dh2906 changed the title fix: JPEG 업로드 시 ImageReader 입력 바인딩 누락으로 인한 변환 실패를 방지 feat: 이미지 리사이징 로직 추가 Mar 21, 2026
@dh2906 dh2906 added the 기능 새로운 기능을 개발합니다. label Mar 21, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java`:
- Around line 76-77: The current ImageConversionService returns image/webp early
and thus skips the size-normalization steps (resizeToMaxWidthIfNeeded,
resizeForWebpIfNeeded) so large WEBP files bypass MAX_UPLOAD_WIDTH /
MAX_WEBP_DIMENSION; change the flow in the method that handles webp detection so
that "skip format conversion" is separated from "skip resizing": detect webp and
if original dimensions exceed MAX_UPLOAD_WIDTH or MAX_WEBP_DIMENSION decode the
webp, run the existing resizeToMaxWidthIfNeeded/resizeForWebpIfNeeded logic and
re-encode to webp bytes before returning, otherwise return the original bytes
unchanged; reference ImageConversionService, resizeToMaxWidthIfNeeded,
resizeForWebpIfNeeded, MAX_UPLOAD_WIDTH and MAX_WEBP_DIMENSION when locating the
code to modify.
- Around line 267-269: The image-type fallback currently forces TYPE_INT_RGB
when image.getType() == 0, stripping alpha and causing transparent PNG/WebP to
render with a black background; change the fallback in resizeImage and the six
transform methods (resizeImage, rotate90, rotate180, rotate270, flipHorizontal,
flipVertical) to choose between BufferedImage.TYPE_INT_ARGB and TYPE_INT_RGB
based on image.getColorModel().hasAlpha(), and ensure any new BufferedImage
created uses that chosen type so alpha is preserved consistently across all
those methods.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ddfe475c-3f6a-4919-bea0-235c5b3f10c2

📥 Commits

Reviewing files that changed from the base of the PR and between 4fa9bfe and 3b25288.

📒 Files selected for processing (5)
  • .gitignore
  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
  • src/test/java/gg/agit/konect/unit/global/auth/web/AuthorizationInterceptorTest.java
  • src/test/java/gg/agit/konect/unit/upload/service/ImageConversionServiceTest.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/test/java/gg/agit/konect/unit/global/auth/web/AuthorizationInterceptorTest.java
  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
  • src/test/java/gg/agit/konect/unit/upload/service/ImageConversionServiceTest.java
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
src/main/java/**/*.java

⚙️ CodeRabbit configuration file

src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.

  • 코멘트는 반드시 한국어로 작성한다.
  • 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
  • 각 코멘트 첫 줄에 심각도를 [LEVEL: high|medium|low] 형식으로 반드시 표기한다.
  • 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
  • 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
  • 가능하면 재현 조건 및 실패 시나리오도 포함한다.
  • 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
  • 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
  • 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
  • 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
  • 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.

Files:

  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
🔇 Additional comments (2)
src/test/java/gg/agit/konect/unit/global/auth/web/AuthorizationInterceptorTest.java (1)

1-1: [LEVEL: INFO] 패키지 선언 경로 정합성 확인됨

package gg.agit.konect.unit.global.auth.web; 선언이 현재 파일 경로와 일치하여 테스트 컴파일/탐색 관점에서 문제 없습니다.

.gitignore (1)

52-53: 이전 제안사항이 올바르게 구현되었습니다.

**/google-service-account.json 패턴을 사용하여 모든 디렉토리 깊이에서 Google 서비스 계정 파일을 무시하도록 설정한 것은 올바른 보안 관행입니다. 이전 리뷰에서 제안된 **/ 접두사가 정확히 적용되어 하위 디렉토리의 파일도 포함됩니다.

@dh2906 dh2906 merged commit 9f7c264 into develop Mar 21, 2026
2 checks passed
@dh2906 dh2906 deleted the fix/reader-iis-bind branch March 21, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

기능 새로운 기능을 개발합니다. 버그 정상적으로 동작하지 않는 문제 상황 관련 이슈입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant