Nodes/petty-paint-comfyui-node/PettyPaintImageDims
ComfyUI Node

PettyPaintImageDims

The dimensions helper that expects a PIL image, not a tensor

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
PettyPaintImageDims
  • image
  • WIDTH
  • HEIGHT

This is a one-trick node: give it an image, get back WIDTH and HEIGHT as integers. That's the whole job, and it's a useful job to have as a first-class node in a graph - dimension ints feed aspect-ratio math, canvas sizing, layout logic, all without you having to eyeball anything.

But there's a catch that will bite you the first time you use it, and it's worth knowing before you wire it up: the input is typed any, and the implementation reads a .size attribute off the first element - image[0].size. That's PIL-image behavior. A raw ComfyUI IMAGE tensor does not have a .size attribute that returns (width, height); tensors have a .size() method, so passing a tensor either errors or gives you something useless. This node is tuned for the petty-paint pack's path-and-PIL-style data flow, where images sometimes arrive as PIL objects rather than tensors.

It's part of the ComfyUI-side integration for Petty Paint, Andrew Porter's web canvas that reimagines your doodles through Stable Diffusion. The pack lives on filesystem paths and app-produced images, which is why some of its helpers assume PIL-style objects.

The honest take

For most workflows, you don't need this node. PettyPaintLoadImage in the same pack already hands you WIDTH and HEIGHT as outputs, and so does the core Load Image flow in many forms. Reach for PettyPaintImageDims only when your image arrives as a PIL-style object - the kind of thing this pack's path-based loading produces - and you don't have a loader in the graph to read dimensions for you.

The inputs and outputs

  • image - any. Feed it something that behaves like a PIL image (i.e. has a .size attribute). A bare IMAGE tensor won't behave.
  • Outputs: WIDTH (INT) and HEIGHT (INT).

Installing it

It ships with the petty-paint pack:

cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node

Restart ComfyUI, or use ComfyUI Manager and search "petty-paint-comfyui-node". Declared dependency is Flask==2.1.2, unused here. Nothing to download.

Common issues

If you wire an IMAGE tensor in and get an error about attribute access or a garbage dimension, that's the PIL-vs-tensor mismatch - switch to reading dims off a loader node instead. The input being any means ComfyUI won't warn you ahead of time, so this is one of those "quietly wrong until it errors" nodes. If you're a beginner, prefer the dimension outputs on the pack's load nodes and skip this one until you actually hit the path-based case.

CategoryPettyPaint

Inputs (1)

NameTypeDefaultDescription
image*

Outputs (2)

NameTypeDescription
WIDTHINT
HEIGHTINT