Skip to content

generate_social_image

nbdev_mkdocs.social_image_generator.generate_social_image(root_path: str, generator: str = 'file', prompt: str = 'Cute animal wearing hoodie sitting in high chair in purple room, browsing computer, 3d render', image_path: Optional[str] = None) -> None async ¤

Generate a custom image for social card using the OpenAI Image API.

Parameters:

Name Type Description Default
root_path str

The root path of the project.

required
generator str

Generator to use to create the social image. Valid options are: 'file' and 'dall_e'.

'file'
prompt str

The prompt to use for generating the image.

'Cute animal wearing hoodie sitting in high chair in purple room, browsing computer, 3d render'
image_path Optional[str]

Image file path to use in the social share image. Use images with a 1:1 aspect ratio and at least 512x512 pixels for the best results. If None, then the default image will be used.

None

Note

The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)

Source code in nbdev_mkdocs/social_image_generator.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
async def generate_social_image(
    root_path: str,
    generator: str = "file",
    prompt: str = "Cute animal wearing hoodie sitting in high chair in purple room, browsing computer, 3d render",
    image_path: Optional[str] = None,
) -> None:
    """Generate a custom image for social card using the OpenAI Image API.

    Args:
        root_path: The root path of the project.
        generator: Generator to use to create the social image. Valid options are: 'file' and 'dall_e'.
        prompt: The prompt to use for generating the image.
        image_path: Image file path to use in the social share image. Use images with a 1:1 aspect ratio and at least 512x512 pixels for the best results. If None, then the default image will be used.

    !!! note

        The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
    """
    image_url = _generate_image_url(root_path, generator, prompt, image_path)

    await _create_social_image(root_path, image_url)

    _update_social_image_in_mkdocs_yml(root_path, image_url)

    _update_social_image_in_site_overrides(root_path)