Command Line Interface (CLI) Instructions for Topaz Photo AI

Hi!,
Can Photo AI be called from a CLI (like terminal in mac, or via a python script)?

I would like to automaticalle upscale all the photos that end in a determined folder.

I know there is a possibility to do this with Gigapixel AI:

import os
import subprocess
import sys

def upscale_image(input_file, output_file, scale_factor):
    # Set the path to the Topaz Gigapixel AI CLI executable
    gigapixel_cli_path = "C:/Program Files/Topaz Labs LLC/Topaz Gigapixel AI/gigapixel-cli.exe"  # Windows
    # gigapixel_cli_path = "/path/to/gigapixel-cli"  # macOS or Linux

    if not os.path.exists(gigapixel_cli_path):
        print("Gigapixel CLI not found. Check the path.")
        sys.exit(1)

    command = [
        gigapixel_cli_path,
        "-i", input_file,
        "-o", output_file,
        "-s", str(scale_factor)
    ]

    try:
        result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        print(result.stdout.decode("utf-8"))
    except subprocess.CalledProcessError as error:
        print(f"Upscaling failed with error: {error}")
        print(error.stderr.decode("utf-8"))

if __name__ == "__main__":
    input_image = "path/to/your/input/image.jpg"
    output_image = "path/to/your/output/image.jpg"
    scale = 2  # Set the desired upscale factor (e.g., 2 for 2x upscale)

    upscale_image(input_image, output_image, scale)

but I would like to do this with Photo AI, and set up the enhance resolution module with its parameters, all in lines of code.

Is it possible?

Thanks!

3 Likes

I would love this option too, then I could also add it into Keyboard Maestro

It would be awesome. I hope a support team dev will read this post

I would also like this option, or some other, to batch-process all files within a specific folder. Right now I’m loading them in about 4000 at a time. It’s very tedious!

Hello all! Topaz Photo AI currently has a command line interface (CLI) for Windows and Mac that is receiving more updates and features. We will be creating an article with instructions on using the CLI soon.

At the moment, the CLI uses Autopilot settings so you can set your Autopilot in the Preferences menu.

Access the CLI with the following commands.
Windows

  • Open command prompt or terminal
  • Type in: cd “C:\Program Files\Topaz Labs LLC\Topaz Photo AI”
  • Type in: tpai.exe --help
  • Hit enter to see options

Mac

  • Open terminal.
  • Type in: tpai --help
  • Hit enter to see options
2 Likes

What is the syntax for tpai.exe, input file(s) first, options first, etc.?