Repository navigation
feat(picture): crop a new picture's sides at the same scale - #447
Merged
Merged
Conversation
add_picture takes crop=(left, top, right, bottom): that much (HWPUNIT) is cut from the sides of the width x height picture, as Hancom crops one -- hp:imgDim keeps the whole picture's size, hp:imgClip the part kept, and the picture is drawn as large as that part, at the same scale. A crop that is not four ints from 0 leaving some of the picture is refused before anything is added (shape-picture-crop-value). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
리뷰 결과: 동작은 맞습니다. 병합 전에 한 줄만 다듬어 주세요.
확인한 것
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
다시 리뷰: 병합합니다. 4a0c4686에서 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
바뀐 점
그림을 만들 때(
doc.add_picture,HwpxOxmlParagraph.add_picture) 네 변을 잘라 낼 수 있다:crop=(왼쪽, 위, 오른쪽, 아래), HWPUNIT.한/글의 동작
한/글은 자른 그림을 이렇게 쓴다.
hp:imgDim에 그림 전체 크기,hp:imgClip에 그 안에서 남길 부분을 쓴다.sz·orgSz·curSz·imgRect)은 남긴 부분만 한 크기다.그래서 축척은 그대로다. 자른 만큼 그림이 작아지고, 남은 부분이 원래 크기로 보인다.
imgClip만 바꾸면, 남긴 부분이 틀 전체로 늘어나 그려진다.imgDim보다 큰imgClip은 그림 밖을 빈 곳으로 그린다.코드
oxml/shape_position.py:validate_picture_crop. 0 이상의 int 네 개여야 하고, 가로·세로 모두 그림이 남아야 한다. 아니면shape-picture-crop-value로 거부한다.oxml/objects.py:_create_picture_element가crop을 받는다. 틀은width - 왼쪽 - 오른쪽xheight - 위 - 아래로 그리고,imgDim은widthxheight,imgClip은 남길 부분이다. 크기 검사를 자르기 검사보다 먼저 한다._document/media.py,document.py: 문서 수준add_picture가crop을 받고, 이진 항목을 넣기 전에 검사한다.errors.py·docs/error-codes.md:shape-picture-crop-value.docs/support-matrix.md(동봉본 동기화),README.md·README_EN.md(알려진 제약, 예제 원장 해시), 변경 로그: 자르기는 지원, 뒤집기·회전은 아직 지원하지 않는다.tests/data/document_facade_surface.json:add_picture서명.테스트
tests/test_picture_adjustments.py:picture_cropped.hwpx(20000 x 10000에서 좌우 5000·위아래 2500을 자름)의orgSz·sz·imgClip·imgDim과 같은 값을 쓰는지 본다. 틀은 10000 x 5000이다.🤖 Generated with Claude Code