Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ pip install -e ".[web]"
ascii-magic-web # http://127.0.0.1:8000
```

**Resize like GIMP**: the rendered art gets drag handles — pull the right edge for width, the bottom edge to stretch/squish the height, or the corner for a free resize (hold **Shift** to keep aspect). A live `cols × rows` readout follows the drag; double-click the ring to reset the height to auto. Works on images, text, and video (video applies on the next Render).

The **Profile** switch in the header applies sensible defaults per target: *Terminal* (SSH greetings, `.ans` output) or *Web page* (larger canvas, filled spaces, `.html` output).

## Docker
Expand Down
3 changes: 2 additions & 1 deletion src/asciimagic/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ def _resolve_caption(
from .text_to_ascii import caption_lines

lines = caption_lines(
caption.text, width, style=caption.style, scale=caption.scale, align=caption.align
caption.text, width, style=caption.style, scale=caption.scale, align=caption.align,
cols=caption.cols, rows=caption.rows,
)
if not lines:
return None
Expand Down
15 changes: 12 additions & 3 deletions src/asciimagic/colorize_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ class CaptionOptions:

text: Optional[str] = None
position: str = "bottom" # "top" | "bottom"
style: str = "block" # block | small | shadow | box | banner
scale: float = 0.6 # fraction of art width for rendered styles
style: str = "block" # block | small | shadow | box | banner | figlet
scale: float = 0.6 # AUTO sizing: fraction of art width for rendered styles
cols: Optional[int] = None # EXACT width in chars (overrides scale; free transform)
rows: Optional[int] = None # EXACT height in rows
gap: int = 1 # blank lines between caption and art
color: Optional[str] = None # theme, #RRGGBB, or "image" (sample the picture); None = default fg
align: str = "center" # left | center | right
Expand Down Expand Up @@ -244,6 +246,10 @@ def build_arg_parser() -> argparse.ArgumentParser:
default="block")
g.add_argument("--caption-scale", type=float, default=0.6, metavar="F",
help="Caption width as a fraction of art width (rendered styles)")
g.add_argument("--caption-cols", type=int, default=None, metavar="N",
help="Exact caption width in chars (free transform; overrides --caption-scale)")
g.add_argument("--caption-rows", type=int, default=None, metavar="N",
help="Exact caption height in rows")
g.add_argument("--caption-gap", type=int, default=1, metavar="N",
help="Blank lines between caption and art")
g.add_argument("--caption-color", default=None, metavar="COLOR",
Expand Down Expand Up @@ -307,6 +313,8 @@ def parse_args(argv) -> Tuple[str, str, Optional[str], Options]:
position=ns.caption_pos,
style=ns.caption_style,
scale=ns.caption_scale,
cols=ns.caption_cols,
rows=ns.caption_rows,
gap=ns.caption_gap,
color=ns.caption_color,
align=ns.caption_align,
Expand Down Expand Up @@ -763,7 +771,8 @@ def _build_caption_lines(cap: CaptionOptions, width: int) -> List[str]:
if not cap.text:
return []
return text_mod.caption_lines(
cap.text, width, style=cap.style, scale=cap.scale, align=cap.align
cap.text, width, style=cap.style, scale=cap.scale, align=cap.align,
cols=cap.cols, rows=cap.rows,
)


Expand Down
6 changes: 6 additions & 0 deletions src/asciimagic/image_to_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ def build_arg_parser() -> argparse.ArgumentParser:
ap.add_argument("--caption-pos", choices=["top", "bottom"], default="bottom")
ap.add_argument("--caption-style",
choices=["block", "small", "shadow", "box", "banner", "figlet"], default="block")
ap.add_argument("--caption-cols", type=int, default=None, metavar="N",
help="Exact caption width in chars (free transform)")
ap.add_argument("--caption-rows", type=int, default=None, metavar="N",
help="Exact caption height in rows")
ap.add_argument("--caption-scale", type=float, default=0.6, metavar="F",
help="Caption width as a fraction of art width")
ap.add_argument("--caption-gap", type=int, default=1, metavar="N")
Expand Down Expand Up @@ -698,6 +702,8 @@ def main():
position=args.caption_pos,
style=args.caption_style,
scale=args.caption_scale,
cols=args.caption_cols,
rows=args.caption_rows,
gap=args.caption_gap,
align=args.caption_align,
)
Expand Down
Loading
Loading