fix: support text rotation in collage zone mode and respect admin set…#1465
Open
flacoonb wants to merge 2 commits intoPhotoboothProject:devfrom
Open
fix: support text rotation in collage zone mode and respect admin set…#1465flacoonb wants to merge 2 commits intoPhotoboothProject:devfrom
flacoonb wants to merge 2 commits intoPhotoboothProject:devfrom
Conversation
…tings Previously, the text rotation configured in the admin panel was ignored when using collage layouts with zone-based text alignment (text_alignment.mode = "zone"). The zone rendering in Image::applyTextInZone() always passed rotation=0 to imagettftext(), and Collage.php allowed JSON layout files to override the admin rotation value. Changes in Collage.php: - Zone-based text alignment from layout JSON is now only applied when "Allow layout selection" (collageAllowSelection) is enabled. When disabled, admin panel coordinates (locationx, locationy, rotation) are used directly via legacy rendering - Admin rotation value always takes priority over JSON layout rotation in both zone mode and legacy mode when layout selection is active - text_disabled from JSON is also only honored when layout selection is enabled Changes in Image.php: - applyTextInZone() now applies the configured rotation angle to imagettftext() instead of hardcoding 0 - Rotated text lines are stacked perpendicular to the text direction using trigonometric offset calculation (sin/cos) so lines appear properly aligned at any angle - Each line is individually centered along the text direction based on its width relative to the widest line - The entire rotated text block is precisely centered within the text zone by calculating the actual bounding box of all rendered glyphs using imagettfbbox() with the rotation angle, then computing the offset needed for proper horizontal (align) and vertical (valign) zone alignment - Admin line spacing (linespace) is respected as minimum distance between lines, preventing text from collapsing when auto-fit reduces the font size - Removed outdated comment "currently only 0 supported" from textZoneRotation property Closes PhotoboothProject#1433
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.
fix: support text rotation in collage zone mode and respect admin settings
Previously, the text rotation configured in the admin panel was ignored when
using collage layouts with zone-based text alignment (text_alignment.mode = "zone").
The zone rendering in Image::applyTextInZone() always passed rotation=0 to
imagettftext(), and Collage.php allowed JSON layout files to override the admin
rotation value.
Changes in Collage.php:
"Allow layout selection" (collageAllowSelection) is enabled. When
disabled, admin panel coordinates (locationx, locationy, rotation)
are used directly via legacy rendering
in both zone mode and legacy mode when layout selection is active
is enabled
Changes in Image.php:
imagettftext() instead of hardcoding 0
using trigonometric offset calculation (sin/cos) so lines appear
properly aligned at any angle
its width relative to the widest line
zone by calculating the actual bounding box of all rendered glyphs
using imagettfbbox() with the rotation angle, then computing the
offset needed for proper horizontal (align) and vertical (valign)
zone alignment
between lines, preventing text from collapsing when auto-fit reduces
the font size
textZoneRotation property
Closes #1433
Prerequisites checklist
What is the purpose of this pull request? (put an "x" next to an item)
What changes did you make? (Give an overview)
When
collage.allow_selectionis enabled and the user selects a collage layoutwith zone-based text alignment (
text_alignment.mode = "zone"), the text rotationconfigured in the admin panel was completely ignored. The text was always rendered
at 0 degrees regardless of the admin setting.
Root cause: Two issues:
Image::applyTextInZone()hardcodedrotation=0in theimagettftext()call,ignoring the
textZoneRotationproperty entirelyCollage.phpallowed JSON layout files to override the admin rotation value(most layouts set
rotation: 0explicitly)Fix:
when disabled, admin coordinates (locationx, locationy, rotation) are used directly
applyTextInZone()now properly renders rotated text with correct line stacking(perpendicular to text direction using sin/cos), per-line centering along the text
direction, and precise bounding-box-based centering within the text zone
Is there anything you'd like reviewers to focus on?
Image::applyTextInZone(): it usesimagettfbbox()with the actual rotation angle to compute the precise boundingbox of the entire text block, then centers it within the zone. This approach
works correctly for any rotation angle (-359 to 359).
$c->collageAllowSelectionguard ontext_alignmentprocessing inCollage.php: this ensures that when layout selection is disabled, the adminhas full control over text positioning via locationx/locationy/rotation.
AI used to create this Pull Request?
Yes, Claude Code (claude-sonnet-4-6) was used to assist with: