Skip to content

renderer: HWP 그림 효과(그레이스케일/흑백) SVG 반영#149

Merged
edwardkim merged 2 commits into
edwardkim:develfrom
marsimon:fix/grayscale-image
Apr 15, 2026
Merged

renderer: HWP 그림 효과(그레이스케일/흑백) SVG 반영#149
edwardkim merged 2 commits into
edwardkim:develfrom
marsimon:fix/grayscale-image

Conversation

@marsimon
Copy link
Copy Markdown
Contributor

요약

Picture 컨트롤의 image_attr.effect(GrayScale / BlackWhite / Pattern8x8)가 렌더러에서 무시되어, HWP에서 그레이스케일 효과가 지정된 그림이 SVG 출력에서는 원본 색상 그대로 나옵니다. 본 PR은 해당 효과를 SVG 필터(feColorMatrix)로 반영합니다.

변경 내용

  • ImageNodeeffect: ImageEffect 필드 추가 (기본 RealPic)
  • Picture 기반 ImageNode 생성 지점 7곳에서 pic.image_attr.effect 전달
    • picture_footnote.rs (2곳)
    • paragraph_layout.rs (3곳)
    • table_cell_content.rs (1곳)
    • shape_layout.rs (그룹 내 그림, 1곳)
  • svg.rs::render_image_node에서 효과별 SVG 필터를 defs에 lazily 등록 후 <g filter=\"url(#...)\">로 래핑
    • GrayScale: luma 가중 feColorMatrix
    • BlackWhite: luma → feComponentTransfer discrete threshold
    • Pattern8x8: SVG로 표현이 어려워 GrayScale로 폴백

테스트

  • cargo test — 785 passed / 0 failed
  • cargo clippy -- -D warnings — 경고 0건
  • 실제 HWP 샘플(그레이스케일 그림 포함) 렌더링 확인: 출력 SVG에 <filter id=\"rhwp-img-grayscale\"> 정의와 filter=\"url(#rhwp-img-grayscale)\" 참조가 올바르게 삽입됨

Picture 컨트롤의 image_attr.effect를 지금까지 렌더러가 무시하고 원본
색상으로 출력했다. HWP의 GrayScale/BlackWhite 효과가 반영되지 않는다.

- ImageNode에 effect 필드 추가 (기본 RealPic)
- Picture 기반 ImageNode 생성 지점(7곳)에서 pic.image_attr.effect 전달
- svg.rs render_image_node에서 효과별 feColorMatrix 필터를 defs에
  lazily 등록하고 <g filter="url(...)">로 래핑
- Pattern8x8은 SVG로 표현이 어려워 GrayScale로 폴백

BlackWhite는 luma → discrete threshold (0/1)로 순흑백 변환.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@edwardkim
Copy link
Copy Markdown
Owner

안녕하세요 @marsimon, 첫 PR 감사합니다! 🎉

코드 변경을 검토했고, 빌드/테스트(785개) 모두 통과했습니다.

로컬에서 렌더링 검증을 하고 싶은데, 그레이스케일/흑백 효과가 적용된 이미지가 포함된 테스트용 HWP 샘플 파일을 함께 올려주실 수 있을까요? samples/ 폴더에 추가해주시면 됩니다.

감사합니다!

복학원서.hwp에는 그림 효과가 GrayScale로 지정된 이미지가 포함되어 있어,
본 PR의 렌더러 수정(ImageEffect → SVG feColorMatrix 필터 래핑)을
회귀 테스트용으로 재현할 수 있다.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marsimon
Copy link
Copy Markdown
Contributor Author

리뷰 감사합니다! 🙏

samples/복학원서.hwp 추가했습니다 (개인정보 없음 확인). 이 파일에 GrayScale 효과가 적용된 그림이 들어있어서, 본 PR 적용 전/후 렌더링 비교로 회귀 테스트 하실 수 있습니다.

cargo run --bin rhwp -- export-svg samples/복학원서.hwp

출력 SVG에서 <filter id="rhwp-img-grayscale"> 정의와 filter="url(#rhwp-img-grayscale)" 참조가 삽입되는 걸 확인할 수 있습니다.

Copy link
Copy Markdown
Owner

@edwardkim edwardkim left a comment

Choose a reason for hiding this comment

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

로컬 검증 완료! ✅

  • cargo test 785개 전체 통과
  • samples/복학원서.hwp SVG 내보내기에서 그레이스케일 필터 정상 적용 확인
    • <filter id="rhwp-img-grayscale"> 정의 생성
    • <g filter="url(#rhwp-img-grayscale)"> 래핑 확인
  • samples/pr-149.hwp로 적용 전/후 렌더링 비교 완료

깔끔한 구현 감사합니다! 🎉

@edwardkim edwardkim merged commit 57b41ba into edwardkim:devel Apr 15, 2026
edwardkim added a commit that referenced this pull request Apr 19, 2026
본 v0.5.0 → v0.7.3 (라이브러리) / 0.2.0 (확장) 배포 주기에
머지된 외부 기여자 6명을 README 3개 변경 이력에 추가:

- @ahnbu — Ctrl+S file handle (PR #189, 기명시)
- @bapdodi — 회전 도형 리사이즈 + Flip (PR #192)
- @dreamworker0 — Windows CFB 경로 (PR #152)
- @marsimon — HWP 그림 효과 SVG (PR #149)
- @postmelee — 썸네일 + options CSP (PR #168)
- @seunghan91 — HWPX Serializer + 다수 (PR #170, #161, #163, #153, #154)

각 README 끝에 "기여자 감사" 섹션 추가 — 6명 일괄 인정.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants