MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / add_logos_to_poster_code

Function add_logos_to_poster_code

utils/logo_utils.py:618–699  ·  view source on GitHub ↗

Add institution and conference logos to poster code. Args: poster_code: Existing poster generation code width_inch: Width of poster in inches height_inch: Height of poster in inches institution_logo_path: Path to institution logo (top-left) conferenc

(
    poster_code: str,
    width_inch: float,
    height_inch: float,
    institution_logo_path: Optional[str] = None,
    conference_logo_path: Optional[str] = None,
    logo_height: float = 2.0,
    logo_margin: float = 0.5
)

Source from the content-addressed store, hash-verified

616
617
618def add_logos_to_poster_code(
619 poster_code: str,
620 width_inch: float,
621 height_inch: float,
622 institution_logo_path: Optional[str] = None,
623 conference_logo_path: Optional[str] = None,
624 logo_height: float = 2.0,
625 logo_margin: float = 0.5
626) -> str:
627 """
628 Add institution and conference logos to poster code.
629
630 Args:
631 poster_code: Existing poster generation code
632 width_inch: Width of poster in inches
633 height_inch: Height of poster in inches
634 institution_logo_path: Path to institution logo (top-left)
635 conference_logo_path: Path to conference logo (top-right)
636 logo_height: Height of logos in inches (default: 2.0)
637 logo_margin: Margin from edges in inches (default: 0.5)
638
639 Returns:
640 Modified poster code with logos added
641 """
642 import re
643
644 logo_code = ""
645
646 # Add institution logo to top-left
647 if institution_logo_path and os.path.exists(institution_logo_path):
648 inst_width, inst_height = get_logo_dimensions(institution_logo_path, logo_height)
649 logo_code += f'''
650# Add institution logo to top-left (aspect ratio preserved)
651institution_logo = add_image(
652 poster_slide,
653 'institution_logo',
654 {logo_margin}, # left
655 {logo_margin}, # top
656 {inst_width}, # width (calculated from aspect ratio)
657 {inst_height}, # height (fixed)
658 image_path="{institution_logo_path}"
659)'''
660
661 # Add conference logo to top-right
662 if conference_logo_path and os.path.exists(conference_logo_path):
663 conf_width, conf_height = get_logo_dimensions(conference_logo_path, logo_height)
664 if logo_code: # Add newline if there's already institution logo code
665 logo_code += '\n'
666 logo_code += f'''
667# Add conference logo to top-right (aspect ratio preserved)
668conference_logo = add_image(
669 poster_slide,
670 'conference_logo',
671 {width_inch - conf_width - logo_margin}, # left (right-aligned with calculated width)
672 {logo_margin}, # top
673 {conf_width}, # width (calculated from aspect ratio)
674 {conf_height}, # height (fixed)
675 image_path="{conference_logo_path}"

Callers 1

new_pipeline.pyFile · 0.90

Calls 3

get_logo_dimensionsFunction · 0.70
findMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected