Dr Kajbaje's, Madhumeha – Diabetes Speciality Clinics

Blog
Diabetic Foot Pain: Causes, Relief Strategies, and Monofilament Testing

Diabetic Foot Pain: Causes, Relief Strategies, and Monofilament Testing

Created At: 2026-07-29T13:00:20+05:30
Completed At: 2026-07-29T13:00:20+05:30
File Path: `file:///d:/workspace/blogs-agent-harness/generate_image.py`
Total Lines: 639
Total Bytes: 22290
Showing lines 1 to 639
The following code has been modified to include a line number before every line, in the format: : . Please note that any changes targeting the original code should remove the line number, colon, and leading space.
1: import asyncio
2: import os
3: import sys
4: import argparse
5: import base64
6: import json
7: from pathlib import Path
8: from playwright.async_api import async_playwright
9:
10: def get_logo_data_url(brand_name):
11: “””
12: Looks inside logos/{brand_name}/ for any image file (png, jpg, jpeg, svg).
13: If found, returns the base64 data URL. Otherwise returns None.
14: “””
15: base_dir = os.path.dirname(os.path.abspath(__file__))
16: logo_dir = os.path.join(base_dir, “logos”, brand_name.lower())
17:
18: if not os.path.exists(logo_dir):
19: return None
20:
21: valid_extensions = {“.png”, “.jpg”, “.jpeg”, “.svg”}
22: try:
23: for file in os.listdir(logo_dir):
24: ext = os.path.splitext(file)[1].lower()
25: if ext in valid_extensions:
26: file_path = os.path.join(logo_dir, file)
27: with open(file_path, “rb”) as f:
28: encoded = base64.b64encode(f.read()).decode(“utf-8”)
29:
30: mime_type = “image/png”
31: if ext == “.svg”:
32: mime_type = “image/svg+xml”
33: elif ext in {“.jpg”, “.jpeg”}:
34: mime_type = “image/jpeg”
35:
36: return f”data:{mime_type};base64,{encoded}”
37: except Exception as e:
38: print(f”Error reading logo for {brand_name}: {e}”, file=sys.stderr)
39:
40: return None
41:
42: # SVG Illustrations
43: SVG_DOCTOR_AVATAR = “””
44: c == “_”])
601: output_path = os.path.join(temp_dir, f”{slug}.png”)
602:
603: try:
604: async with async_playwright() as p:
605: browser = await p.chromium.launch()
606: page = await browser.new_page(viewport={“width”: 1200, “height”: 630})
607: await page.goto(Path(html_path).resolve().as_uri())
608: await page.wait_for_timeout(400)
609: await page.screenshot(path=output_path)
610: await browser.close()
611: print(f”IMAGE_GENERATED_PATH:{output_path}”)
612: finally:
613: if os.path.exists(html_path):
614: os.remove(html_path)
615:
616: if __name__ == “__main__”:
617: parser = argparse.ArgumentParser(description=”Generate infographic featured images.”)
618: parser.add_argument(“–keyword”, required=True, help=”Primary keyword or topic”)
619: parser.add_argument(“–brand”, required=True, help=”Brand name (e.g. madhumeha, zenyva)”)
620: parser.add_argument(“–phone”, help=”Optional phone number”)
621: parser.add_argument(“–url”, help=”Optional website URL”)
622: parser.add_argument(“–output”, required=True, help=”Output image file path”)
623: parser.add_argument(“–bullets”, help=”Semicolon-separated or JSON array of 3 key takeaways”)
624: parser.add_argument(“–layout-type”, default=”infographic_bullets”, choices=[“infographic_bullets”, “doctor_patient”, “comparison_grid”], help=”Layout template style”)
625: parser.add_argument(“–subtitle”, help=”Optional custom subtitle text”)
626:
627: args = parser.parse_args()
628:
629: asyncio.run(generate_featured_image(
630: keyword=args.keyword,
631: brand=args.brand,
632: phone=args.phone,
633: url=args.url,
634: output_path=args.output,
635: bullets=args.bullets,
636: layout_type=args.layout_type,
637: subtitle=args.subtitle
638: ))
639:
The above content shows the entire, complete file contents of the requested file.

Leave a Reply

Your email address will not be published. Required fields are marked *