summaryrefslogtreecommitdiff
path: root/internal/comic/pageframe.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-23 09:06:37 +0300
committerPaul Buetow <paul@buetow.org>2026-04-23 09:06:37 +0300
commit1834c8886b15aa3b868e988c185ac5c344392886 (patch)
tree89bab79059910638b7f8b3f865e9feddf95f4b81 /internal/comic/pageframe.go
parent0ccc8073852895996ed70c4b2a86c460e3a3ddae (diff)
Add ISO A4 PDF print/book pipeline, page-frame prompts, and usage docs
Print and book PDF modes now letterbox each raster to A4 portrait at pdf.density; print uses the matte color for pads. CLI forces 3:4 generation for print|book unless --aspect-ratio is set. Cover, gallery, and back prompts gain DINA4PDF instructions when those modes are active. Introduce DescribePageFrame and PDF helpers with tests; add CLI tests for presentation and aspect precedence. Expand README and config example with A4 examples, language env vars, and page-format vs PDF behavior. Add sample Sumer vocabulary files. Made-with: Cursor
Diffstat (limited to 'internal/comic/pageframe.go')
-rw-r--r--internal/comic/pageframe.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/comic/pageframe.go b/internal/comic/pageframe.go
new file mode 100644
index 0000000..82ab363
--- /dev/null
+++ b/internal/comic/pageframe.go
@@ -0,0 +1,36 @@
+package comic
+
+import (
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+// DescribePageFrame returns human-readable page shape text for image prompts,
+// derived from a Gemini-style aspect ratio such as "16:9" or "2:3".
+func DescribePageFrame(aspectRatio string) string {
+ aspectRatio = strings.TrimSpace(aspectRatio)
+ if aspectRatio == "" {
+ aspectRatio = comicPageAspectRatio
+ }
+ parts := strings.Split(aspectRatio, ":")
+ if len(parts) != 2 {
+ return fmt.Sprintf("%s format", aspectRatio)
+ }
+ w, errW := strconv.Atoi(strings.TrimSpace(parts[0]))
+ h, errH := strconv.Atoi(strings.TrimSpace(parts[1]))
+ if errW != nil || errH != nil || w <= 0 || h <= 0 {
+ return fmt.Sprintf("%s format", aspectRatio)
+ }
+ switch {
+ case w < h:
+ if w == 3 && h == 4 {
+ return "portrait 3:4 format (ISO A4–class sheet: 210×297 mm target; image API uses 3:4 as the closest standard ratio)"
+ }
+ return fmt.Sprintf("portrait %s format (tall comic book page proportions)", aspectRatio)
+ case w > h:
+ return fmt.Sprintf("landscape %s format (widescreen)", aspectRatio)
+ default:
+ return fmt.Sprintf("square %s format", aspectRatio)
+ }
+}