Match Texture Aspect Ratio
1 avatar mesh into the right shape
- BPY_OBJ
- image
- BPY_OBJ
Of the twenty Object_ nodes in Avatar Graph, this is the one the pack's own README calls out - and the one you'll actually use. Object_MatchTextureAspectRatio is not a generated bpy wrapper like its siblings; it's a hand-written node that fixes a specific quirk of this pack's pipeline: the mesh created from your character image is built in a 1:1 square, but your source texture almost certainly isn't square. Without this node, your rigged avatar comes out stretched into a square, with the face looking like it's been through a funhouse mirror.
How it works. It's an EditOps node, so it takes your BPY_OBJ, enters edit mode, selects all mesh vertices, and runs a resize transform. But it doesn't resize blindly - it reads the actual dimensions of the image you feed in and computes the target width and height from them. From the source:
height, width = image[0].shape[:2]
width, height = (width * scale, height * scale)
bpy.ops.transform.resize(value=(width, height, 0))
So the mesh's width and height get scaled to match the texture's pixel aspect ratio, and the depth stays flat - which is exactly right for a 2D-character mesh that's about to be animated as a flat card with shape keys.
The inputs that matter:
BPY_OBJ- the mesh layer you created from the segmented character image.image- the original texture image (or one with matching dimensions). This is the reference for the aspect ratio.scale- a multiplier, default0.001. Since mesh coordinates and pixel dimensions live on different scales, this bridges them; 0.001 maps roughly 1 pixel to 0.001 Blender units. If your mesh comes out huge or tiny, adjust this, not the image.
Output. BPY_OBJ, the resized mesh, passed straight to the next node - typically a UV unwrap or a shape-key setup.
Installing it. Ships in Avatar Graph via ComfyUI Manager ("Avatar Graph") or:
cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui
cd avatar-graph-comfyui
python -m pip install -r requirements.txt
Restart with --enable-cors-header. Pack pins bpy==3.6.0 → Python 3.10.x required.
Troubleshooting. Feed it the same image you used to create the mesh layer, or you'll stretch the mesh to the wrong ratio. If the mesh ends up rotated or mirrored, remember the resize happens in the mesh's local space - a mesh whose own axes aren't aligned to the image can behave oddly. And don't skip the README's advice about input images: feed the pack a character shot of at least 768×768 with an open mouth; the aspect fix works better on a decently-sized source. This node sits at the end of the mesh-creation chain precisely because that's where the square-mesh problem becomes visible.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| BPY_OBJopt | BPY_OBJ | — | |
| imageopt | IMAGE | — | |
| scaleopt | FLOAT | 0.001 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BPY_OBJ | BPY_OBJ | — |