Skip to content

Crop in pixel space instead of point space - #54

Merged
benedom merged 2 commits into
masterfrom
fix/crop-pixel-space
Jul 31, 2026
Merged

Crop in pixel space instead of point space#54
benedom merged 2 commits into
masterfrom
fix/crop-pixel-space

Conversation

@benedom

@benedom benedom commented Jul 31, 2026

Copy link
Copy Markdown
Owner

calculateCropRect measured against PlatformImage.size while CGImage.cropping(to:) cuts in pixels. The two differ whenever an image carries DPI metadata other than 72 on macOS, or a scale other than 1 on iOS, so the result came out too small and offset towards the top left.

The circular crop renders in point space and was never affected.

`calculateCropRect` measured against `PlatformImage.size` while
`CGImage.cropping(to:)` cuts in pixels. The two differ whenever an image
carries DPI metadata other than 72 on macOS, or a `scale` other than 1 on
iOS, so the result came out too small and offset towards the top left.

The circular crop renders in point space and was never affected.
@benedom benedom added the bug Something isn't working label Jul 31, 2026
@benedom
benedom merged commit 7344495 into master Jul 31, 2026
3 checks passed
@benedom
benedom deleted the fix/crop-pixel-space branch July 31, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant