ComfyUI Node

GCP: Read Image

Drag images straight out of a Google Cloud Storage bucket

By ahernandezmiro·Created 2 years ago·Updated 2 years ago· 5
GCP: Read Image
    • image
    bucket_namemy-bucket
    bucket_pathsome/folder
    file_namemy_image.png
    gcp_service_json/path/to/service_account.json

    If your reference images, training sets, or upstream pipeline output live in a Google Cloud Storage bucket, this node is the "stop downloading by hand" button. It pulls one blob from GCS, decodes it, and hands you a standard ComfyUI IMAGE tensor that wires straight into a VAE encode, a ControlNet preprocessor, or img2img. It's the read half of a two-node pack - the sibling GCPWriteImageNode does the upload back.

    You reach for it when your workflow is more pipeline than hobby: a cron job that drops new source images into a bucket, a shared team asset folder, or a headless box that shouldn't keep a local mirror of everything. If you're a single user on a single machine who saves everything locally, skip it - you don't need a cloud round-trip. But if the images you generate against already live in GCS, this saves you from maintaining a copy of the bucket.

    How it works

    The mechanism is straightforward and not very clever, which is fine. You give it a service-account key (a JSON file, not your personal Google login), it sets the GOOGLE_APPLICATION_CREDENTIALS environment variable, and the google-cloud-storage client does the rest through Application Default Credentials. It downloads the blob to a temp folder inside the pack's own directory, opens it with PIL, applies exif_transpose (so phone photos don't come back sideways), converts to RGB float32 in the usual [1, H, W, 3] range, and deletes the temp file after loading. No persistent disk copy left behind.

    One path detail that trips people: the object it fetches is assembled as bucket_path + the basename of file_name. If you type folder/img.png into file_name, the folder/ part is silently stripped and it looks for bucket_path/img.png instead. Keep bucket_path as the real folder and file_name as just the name.

    The inputs that matter

    All four inputs are plain strings - there's nothing to set per-run except these:

    • bucket_name - your bucket. GCS bucket names are globally unique, so this is exact.
    • bucket_path - the folder inside the bucket (default some/folder is a placeholder, see below).
    • file_name - the image's filename, basename only.
    • gcp_service_json - the absolute path to your service-account JSON. If you give a relative path it's resolved against the pack's own directory, which is almost never what you want.

    Output: image - a single IMAGE tensor, ready to plug into anything that takes an image. It returns one image per call; for a batch you're calling the node multiple times.

    Installing it

    Either search ComfyUI Manager for "ComfyUI-GCP_Storage_tools", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ahernandezmiro/ComfyUI-GCP_Storage_tools gcp_nodes
    pip install google-cloud-storage
    

    Restart ComfyUI after that. The pack's __init__.py tries to auto-install google-cloud-storage on startup if it's missing, but that self-install is fragile (it shells out to pip inside ComfyUI); installing it yourself is the reliable path. That single dependency plus the service-account JSON is the whole setup.

    Where people get burned

    • The placeholder defaults. Leave bucket_name as my-bucket or gcp_service_json as /path/to/service_account.json and you get a hard FileNotFoundError: Credential file not found - the node checks the file exists before anything else. Set all four fields, every run.
    • Wrong key type. This needs a service account JSON with storage.objectViewer (read) permission on the bucket. Your user-account credentials won't work, and a key for the wrong project just 404s.
    • Path mismatch. If the object isn't at exactly bucket_path/basename(file_name), you get a 404-style failure. Check the printed log line - it echoes the full gs://bucket/path it's fetching.
    • No retries, no polish. Errors just re-raise and print to the console. If GCS is flaky mid-run, you re-run.

    It's a bare-bones node with zero community footprint - you're on your own beyond the README. For a more feature-complete cloud-save story, the community's bigger projects (like ComfyUI Save/Load Extended) cover GCS alongside S3, Drive, and Azure with a nicer UI. But if you just want "fetch that image from the bucket," this does exactly that with one input string.

    Categorygcp_storage

    Inputs (4)

    NameTypeDefaultDescription
    bucket_nameSTRINGmy-bucket
    bucket_pathSTRINGsome/folder
    file_nameSTRINGmy_image.png
    gcp_service_jsonSTRING/path/to/service_account.json

    Outputs (1)

    NameTypeDescription
    imageIMAGE