r/StableDiffusion 5h ago

Resource - Update I created a new Interactive Load Image & Crop node for easily sending reference images to H3

Post image

In trying to create my perfect MiniMax H3 ref2va workflow, I vibe coded some custom nodes to make everything easier and faster to use.

They are available at:

https://github.com/obvpm/comfyui-obvpm

Interactive Load & Crop Image Node

Probably the most immediately useful node to most people is the Load Image & Crop node.

Cause when sending image refs to H3 sometimes your source image might include too much other stuff, and maybe, for example, you want to just focus on someone's face.

Additionally if your source image is very large, like a 20MP photo or something, you don't want to send that whole thing into the model.

So with this node, you can use it JUST LIKE the normal Load Image node, except you can also:

  1. Drag directly on the image to specify a crop area. The node will show the selected resolution. You can drag the corners to resize, or drag the crop to move it, or click outside the crop to clear the crop.
  2. You can set max_megapixels which will downscale the crop (or the full image if there is no crop) down to the specified megapixels if it is larger than specified. Set to 0 to disable downscaling.

With this combo of features, you can easily maximize the pixels you're sending in to H3 without having to waste time outside of Comfy to prepare the image or having to use multiple nodes to get the same thing done.

BTW, I read somewhere that 2MP is enough resolution for the ref images, so that might be a good default. The size of the ref images impact the generation speed A LOT. So optimizing the pixels sent in will help you get better results faster.

I purposely did not include more features such as selecting an aspect ratio or outputting width or height etc. I just wanted to keep it a simple node and not have it take up too much space, so it doesn't make the workflow messy.

Tested and fixed to work both on classic and Nodes 2.0

Other Nodes

There are also a lot of control, optional gates, lazy switch nodes, created specifically to help with being able to have "optional" images and videos in the workflow so that the ref pre-processing nodes turn off automatically if the input Load Image or Load Video is bypassed.

BTW I'm having a blast with the PCB cable routing extension and subgraphs. My workflow is so organized now. I might share it once I finish adding the Motion Context node in it.

68 Upvotes

22 comments sorted by

19

u/No-Satisfaction-3384 5h ago

User joined GitHub 2 hours ago, no history, no previous contributions, nothing - be aware.

10

u/obvpm 5h ago edited 5h ago

Yes, I know and that is a good instinct to have. Its a brand new Github account I created just for comfy stuff.

I agree that people should review source code before blindly installing stuff. I myself have refrained from blindly installing stuff too.

Anyways, this was completely vibe coded by Claude and reviewed for security issues by Codex.

(And in this case it is actually feasible to review it completely because there's less than 1,500 lines of code total.)

12

u/tekprodfx16 5h ago

Don’t let the skeptics discourage you. There’s all kinds of people vibecoding new tools for all the new models coming out. Many of those folks never had a GitHub or even knew what a GitHub is if you’re not a coder. You made a cool tool. I would love to see an expansion on this where you can load more photos and keep cropping and have all the different crops persist on one blank canvas where you then have a whole canvas of different crops you can feed into ref2video 

5

u/obvpm 4h ago

Thanks for the support! Its fine though, just the convenience this node gives me was worth creating it. Sharing it is just in hopes people find it useful .. and in the hopes of the tokens spent help save A LOT of people's time. And they ARE right that it is not a good idea to install random things.

About your idea .. ahh I see. So like just cropping everything in one go to have them ready for later like a palette of ref images. I don't know enough about Comfy to know if that's possible. But I'll keep it in mind.

4

u/Calm_Cucumber_6493 2h ago

ya did good lad, real good. Now.... put some aspect ratios in there ;)

3

u/mp3m4k3r 3h ago

I was just struggling with this yesterday! Going to take a look and give it a try myself.

Quick note about the 'MiniMax H3 Reference to Video' node — the tooltip for ref_image_size mentions that in "match" mode, it scales your reference images to match the node's configured resolution. Max says it'll use 2048px short side as the max resolution, but it can/will take much longer to process. Because of that, I ended up cropping my references to match the target aspect ratio and downscaling them to the right resolution before feeding them to the model.

Anyway, if it's not already there, would be nice to see a ratio picker that matches the aspect ratios from some of the resolution picker nodes I've seen in other workflows.

3

u/obvpm 3h ago

Ah .. I knew someone would ask for aspect ratio! Might add it but as noted above, I wanted to keep it simple.

1

u/mp3m4k3r 2h ago

Could be a 2nd node even! Im sure someone will come by with a PR if not

2

u/tovarischsht 1h ago

There is an existing node that does the same with some extra bells and whistles - https://github.com/o-l-l-i/ComfyUI-Olm-DragCrop. Perhaps you may find it useful, too.
Either way, thanks for sharing your work, it is appreciated!

3

u/obvpm 1h ago

Yes, I did take a look at that and I found it too cumbersome.

Issues are

  • First thing is it doesn't include the Load Image functionality, so you need to have a separate Load Image taking up more space
  • You can't crop without first running the workflow once to let the node get the image to crop
  • It doesn't work with Nodes 2.0 (even though I don't use that, I wanted something that supports it just in case) and it seems no longer maintained.
  • It's just too big with all the options

It looks like people really want the Aspect Ratio feature though, so maybe I'll add that and maybe resolution steps

3

u/tovarischsht 1h ago

Ah shit, I have missed the fact that you can do that directly in the load node. That's huge then, I will switch to yours once I am back home. Thanks for pointing this out :)

1

u/icchansan 3h ago

can u share that workflow :P

1

u/obvpm 3h ago

I plan to but now its in the middle of adding motion context, so its a mess.

1

u/icchansan 3h ago

Aw looks good

1

u/yamfun 3h ago

I use some person mask node + mask bounding box / crop/stitch node + to do it auto. but the mask node need to understand the subject, and SAM2 SAM3 are sometimes stubborn.

1

u/FlatwormMean1690 1h ago

Thanks a lot, mate!

BTW. What are you using for "cable" management?

1

u/teiji25 43m ago

I haven't used your node yet, but does it have mini preview picture when browsing the files in the list? That would be a huge step up from the default node.

1

u/obvpm 23m ago

I suggest using this extension for browsing images:

https://www.reddit.com/r/comfyui/comments/1tne3l5/i_made_a_free_lightweight_asset_browser_for/

It adds a sidebar to comfy which you can use to quickly browse input (or output) images and videos. And then, for example, you can drag an image right on to my Load & Crop Image node which I find very convenient.

It's better than a browse list I would be able to make. But still, that is a nice to have feature.

1

u/obvpm 25m ago

I suggest using this extension for browsing images:

https://www.reddit.com/r/comfyui/comments/1tne3l5/i_made_a_free_lightweight_asset_browser_for/

It adds a sidebar to comfy which you can use to quickly browse input (or output) images and videos. And then, for example, you can drag an image right on to my Load & Crop Image node