M Int GCD
Greatest common divisor in your image graph? Sure, if you need it
- gcd
Let's be honest about M Int GCD up front: it's a number-theory node in an image tool, and most workflows will never touch it. But it's in the pack because the pack author clearly wrote the math toolkit for themselves, and once you've seen the use case you'll understand why it's there. gcd(a, b) returns the greatest common divisor of two integers as an INT named gcd.
The actual uses in a ComfyUI context, rare as they are, are real:
- Finding the base unit. If your width and height are both multiples of some base block (512 and 768), gcd(512, 768) = 256 - the largest tile size that divides both evenly. That's the mathematical answer to "what's the biggest tile I can use for both dimensions without cropping."
- Simplifying ratios. gcd is what you'd use to reduce a ratio to its simplest form - divide both sides by their gcd and you have the clean aspect ratio instead of a big pair of numbers.
- Multi-value coordination. If several of your workflow's sizes must all divide by a common factor, gcd tells you the largest one that works.
Mechanically it's Python's math.gcd, with the standard behavior you'd expect: gcd(0, n) is n, and it's always non-negative. Inputs a and b are signed 32-bit INT, defaults 0.
It ships in ComfyUiNodes (repo Madlumi/ComfyUiNodes, author "Madanie"), a small personal pack of integer math, string helpers, and workflow-glue nodes. Install via ComfyUI Manager - search "ComfyUiNodes" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/Madlumi/ComfyUiNodes
Restart ComfyUI afterward. No pip requirements or model downloads. Find it under Add Node → mnodes → int.
The honest verdict: install the pack for the workflow-glue nodes and the LoRA loader, and let gcd sit in the menu as a nice-to-have. The day you're puzzling over tile sizes that won't divide evenly, it's the difference between guesswork and a number you can trust.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT | 0-2147483648–2147483647 | — |
| b | INT | 0-2147483648–2147483647 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| gcd | INT | — |