Skip to content

feature: allow selection of different collage layouts#1362

Merged
andi34 merged 21 commits intodevfrom
collage/select
Jan 6, 2026
Merged

feature: allow selection of different collage layouts#1362
andi34 merged 21 commits intodevfrom
collage/select

Conversation

@andi34
Copy link
Copy Markdown
Contributor

@andi34 andi34 commented Dec 29, 2025

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)

Allow to enable collage selection on start page.
Take frames and backgrounds depending on collage layout (prefix).
Choose disabled layouts.

Is there anything you'd like reviewers to focus on?

To-Do:

  • [ ]needs documentation
    • Take frames and backgrounds depending on collage layout (prefix) description/info

@andi34 andi34 requested a review from reloxx13 December 29, 2025 16:14
Comment thread template/components/collageSelection.php Outdated
@reloxx13
Copy link
Copy Markdown
Collaborator

Add touch-friendly collage layout modal and unify selection flow

grafik

@dasGOLE
Copy link
Copy Markdown
Collaborator

dasGOLE commented Dec 30, 2025

I've tested it on my PB and it looks good. Maybe it would be even better, if we can add a preview of the Layout in addition or instead of the Layout name, so users know how the result would look like. Maybe the Previews / Pictures from the Collage test. 🤔
It's something I'm considering for the Designer as well (for the dropdown selection).

@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 2, 2026

Needs collage limit to be adjusted after selecting . Currently Throwing an error because using the count of default defined layout
Screenshot_20260102-172346

@andi34 andi34 force-pushed the collage/select branch 6 times, most recently from 79b38c4 to 5eea975 Compare January 3, 2026 17:43
andi34 and others added 15 commits January 3, 2026 19:34
Change-Id: I8ddfa3e4858122f2195bc89d0f0aa83869e31d48
Change-Id: Ibe8f0e03776a24eb8cbca5c91da5516baccf8ebf
Change-Id: I0c0421fb9eb43c11d2720b5e120e0fac8db68314
Change-Id: I55c8bed0b374d703aea769f95f7bc4614c210202
Change-Id: I31d812918bd3596ca61bb9b57af778455672915e
Implement comprehensive visual previews for all collage layouts to improve
user experience and reduce confusion during layout selection. Users can now
see exactly how their collage will look before capturing photos.

- Added `getLayoutPreviewSvg()` function to generate SVG preview for each layout
- Visual previews show numbered photo positions (1, 2, 3, 4, etc.)
- Blue boxes (#4A90E2) with white numbers indicate photo placement
- Landscape format (3:2 aspect ratio, 180x120 viewBox) for 10x15cm prints

All collage layouts now have accurate visual previews:
- 2+2 Layout (Options 1 & 2): 4 equal rectangles with/without padding
- 1+3 Layout (Options 1 & 2): 1 large + 3 small photos
- 3+1 Layout: 3 small + 1 large photo
- 1+2 Layout: 1 large + 2 small photos
- 2+1 Layout: 2 top + 1 bottom photo
- 2x4 Layout (Options 1-4): 4 photos duplicated (strip format)
- 2x3 Layout (Options 1-2): 3 photos duplicated (strip format)

Special visualization for photostrip layouts (2x4, 2x3):
- Red dashed cut line in the middle shows where strip will be cut
- Scissors icon (✂) indicates cutting position
- Photos numbered identically on both halves (duplicates)
- Shows that strips are printed and then cut in half

- Grey outer border shows final photo format
- Light grey background container for each preview
- Structured button layout: SVG preview → label → photo count
- Added CSS classes: `.collageSelector__preview-container`,
  `.collageSelector__preview`, `.collageSelector__label`

- PHPStan Level 8 compliant with proper type annotations
- PHP-CS-Fixer compliant formatting
- Added @var annotation for $config variable
- Clean separation of layout definitions based on JSON files

**Modified Files:**
- `template/components/collageSelection.php`: Added SVG generation function
  and updated button rendering with visual previews (49 → 227 lines)
- `assets/sass/components/_button.scss`: Added CSS for preview styling
- `resources/css/framework.css`: Compiled SASS output

**Preview Generation:**
- SVG viewBox: 180x120 (landscape 3:2 format)
- Position calculations based on landscape JSON layout definitions
- Dynamic rendering based on CollageLayoutEnum value
- Rectangle fill: #4A90E2, stroke: #FFFFFF (2px)
- Font: 28px bold, centered in each position box

**Layout Accuracy:**
All SVG positions calculated from actual JSON files in
`template/collage/landscape/*.json` to ensure preview matches final result.

Change-Id: Ib83722930cc9d73e56626411684e8fa06b32142b
- Replace hardcoded SVG coordinates with dynamic JSON parsing
- Read layout positions from template/collage/landscape/*.json files
- Evaluate expressions (x*0.5, y/2, etc.) at runtime
- Calculate viewBox dimensions from actual template width/height
- Single source of truth: JSON files define both collage and preview
- Automatically supports custom templates and community layouts
- No manual coordinate maintenance needed

Benefits:
- JSON changes are instantly reflected in previews
- Correct aspect ratios for all layouts
- Supports any template format (landscape/portrait)
- Eliminates duplicate coordinate definitions
- Future-proof for new template additions

Change-Id: I1150367bd433f4ac4c1c3a02f10d8f56c37b6824
- Photostrip layouts duplicate photos (left/right halves are cut)
- Second half now shows numbers 1-4/1-3 again (not 5-8/4-6)
- Display: Left: 1,2,3,4 | Right: 1,2,3,4 (duplicates)
- Logic checks if layout is photostrip and resets numbering
- Normal layouts (2+2, 1+3, etc.) unaffected

Change-Id: I416a7607aa61f3ef32d62b579c8fce02813ece16
- Read orientation from config (landscape/portrait)
- Pass orientation to loadCollageLayoutFromJson()
- Previews now use correct template files based on admin setting
- Portrait: 1200×1800 (2:3), Landscape: 1800×1200 (3:2)
- ViewBox and photo positions adapt automatically

Change-Id: I033ba13c7bebf9fd0f9ad40018290af6644d6fa1
Change-Id: I93e212f881af9162635d3ffd132bbe69de9065bf
- Add zone-based text system with configurable alignment and positioning
  - Support for horizontal alignment (left/center/right) per line
  - Vertical alignment with proper baseline correction
  - Auto-fit font sizing within defined zones
- Extend text duplication for 2x layouts to both orientations
  - Landscape: horizontal duplication (shift X coordinate)
  - Portrait: vertical duplication (shift Y coordinate)
  - Full support for zone mode in duplicated text
- Fix PHP 8.4 compatibility issues in Image.php
  - Replace static method calls with instance method calls
  - Affects resizeCropImage(), applyFrame(), rotateResizeImage()
- Add zone text configuration to all collage templates
  - Define text zones with x, y, width, height, padding
  - Set alignment parameters (align, valign) per template
- Update CollageConfig DTO to support zone text parameters

Change-Id: Icb6dfd8d316e564d56c036ccb8ec5e5ffe8e7b6e
Change-Id: I209d6afe3c1a5438d125968c9e47db3ba8f1cacb
flacoonb and others added 3 commits January 3, 2026 21:02
- Replace plain HTML/CSS with Photobooth admin components
- Add navigation buttons (Admin Panel, Test Menu, Layout Generator)
- Implement responsive Tailwind grid layout (1/2/3 columns)
- Fix scrolling with absolute positioning and overflow-y-auto
- Use admin head/footer components for consistent styling
- Add LanguageService integration for translations

The test page now matches the design and UX of other test pages
like collage.php and photo.php.
Change-Id: I0a4add8906d495cf649fdd3fa2f07567e8b1d047
Change-Id: I3d659b77ebcc0526460605a29d31445cde5d7749
Move collage handling for frame and background to collage processing.

Change-Id: I0bd35e322e99484d38119e4dd282b662db81c885
@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 4, 2026

Moved layout specific frame & background detection to src/Collage, handle centralized and make reusable function.
No need to adjust collage test page now to use matching frame if possible.

@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 4, 2026

Docs changed might need formatting, will try checking later today.

Anything else left?

@andi34 andi34 requested a review from reloxx13 January 4, 2026 13:13
Copy link
Copy Markdown
Collaborator

@dasGOLE dasGOLE left a comment

Choose a reason for hiding this comment

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

should we not implement the Background and Frame config within the json file? Therefore one Background could be configured for multiple Layouts, without the need to dublicate the Picture for each layout.

Something like this:
{
"name": "1+2 Layout",
"author": "PhotoboothProject",
"aspect_ratio": "3:2",
"width": "1800",
"height": "1200",
"layout": [
["x0.02810", "y0.0800", "x0.4978", "y0.4978", "0"],
["x0.02810", "y0.6178", "x0.3052", "y0.3052", "0"],
["x0.34736", "y0.6178", "x0.3052", "y0.3052", "0"],
["x0.66662", "y0.6178", "x0.3052", "y0.3052", "0"]
],
"text_alignment": {
"mode": "zone",
"x": "x0.55",
"y": "y
0.1",
"w": "x0.42",
"h": "y
0.42",
"align": "center",
"valign": "middle",
"rotation": 0,
"padding": 0
},
"Background": "demopic.png",
"Frame": "frame.png"
}

@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 4, 2026

I'd keep this as is.
If layout specific frame or background not exists, it's taking the default defined anyway. You can upload layout specific, but don't have too. You can define one per layout without prefix.

@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 4, 2026

Where the implemented solution helps, background in most cases won't be needed as the frame can cover the whole image (you onlyneed the transparent parts specific for the layout).

Adminpanel config:

  • Apply frame to collage once
  • Define frame without prefix, let's sayframe.png.

Now upload frame.png and frame.png with prefix for every allowed layout with specific transparent parts (e.g. 1+2-1_frame.png and 2+2-2_frame.png).

While processing the collage it'll take {layout}_frame.png if exists without defining it explicitly. IMO more user-friendly and more advanced as you can still define a frame with unique name via Json file.

@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 4, 2026

Also see https://photoboothproject.github.io/faq/custom-collage/#extended-collage-object-v499 , already supported via json.

@andi34
Copy link
Copy Markdown
Contributor Author

andi34 commented Jan 5, 2026

Still Docs formatting not fitting, also collage.json_{layout} needed (needs adjustment)... Else looks good IMO and ready once this is done.

andi34 and others added 2 commits January 6, 2026 07:28
Change-Id: Ie438eb18755cfb66c60bb8a4ddc51f5e13568791
@reloxx13
Copy link
Copy Markdown
Collaborator

reloxx13 commented Jan 6, 2026

nice idea with the preview blocks in the selection!
so far works fine, code looks good. i found some left over console logs which are removed now.

@andi34 andi34 merged commit 8c4f845 into dev Jan 6, 2026
9 checks passed
@andi34 andi34 deleted the collage/select branch January 6, 2026 17:25
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.

[FEATURE]: Support different collage options from frontpage instead of admin

4 participants