crop empty space around generated text

Recommended Posts

I need to generate text in Houdini and render it so that the empty area outside the generated text is cropped. The saved image should only be the size that is needed to display the generated text and not the default canvas size of 1920x1080. I am using the Compositing context very infrequently, so I was wondering if there is an easy way to determine the size of the generated text automatically and control a Crop node with that information.

Share this post

Link to post

Share on other sites

I would alter the camera's resolution based on the bounding box of the text its self before rendering, if that's an option available to you.

That's one way I could do it in the OBJ context: Generate text geometry, position a camera and invoke Mantra. But is there a way to do it completely in the Compositing context? The IMG context also has a font node that can generate text, but it generates a default canvas of 1920x1080. I would need to determine the bounding box of the text somehow in the Compositing network and feed that information to the crop node. Unfortunately I am not familiar with the IMG network. I could not find something like a detail attribute that I could generate in a VopCop node (for storing the bounds of the colored text) and later in the network access this attribute in the Crop node. My way of thinking in the OBJ context does not work in the IMG context

Share this post

Link to post

Share on other sites

I'm pretty sure you're going to have to use the SOP context if you need this to be auto-magical. So, if you're stuck with the images and can't re-render them, I suggest using the Trace SOP to generate geo from your images and then bbox from there. Otherwise, if you're completely set on doing it entirely in COPs you'll probably need to do some VEX magic looking at every freaking pixel and write reams of code (10-20 lines?).

Share this post

Link to post

Share on other sites

Thanks for the tip. Is there a way to call iautocrop from the "Post-Render Script" field in my ROP File Output node, which is attached at the end fo the network?

Another solution that would work with the ROP would be to crop the image using python after it is written on disk.

Sorry for the late answer... Well, I do not know, since I never have used this command, have in mind this is a stand alone tool, not a script. My guess is that there must be a way to create a python script to launch the tool. But I guess you will need to do that research yourself. It all comes down on how often you will need to do this, I run commands from Houdini Cmd Line constantly to run little tools, and it is just one line, so you can easily just make a txt file with the template you need to run.

Share this post

Link to post

Share on other sites

I found a quite elegant way to do that task without setting up a camera or cropping via a post processing script.

1. In the OBJ context: set up a Font node.
2. In the IMG context: set up a "Geometry" node (which renders SOPs along a world axis) and control the node's "Overide Size" Parameter via the bounding box of the Font node from the OBJ context.

Share this post

Link to post

Share on other sites

I found a quite elegant way to do that task without setting up a camera or cropping via a post processing script.

1. In the OBJ context: set up a Font node.
2. In the IMG context: set up a "Geometry" node (which renders SOPs along a world axis) and control the node's "Overide Size" Parameter via the bounding box of the Font node from the OBJ context.

Yes I thought about the geo node in cops aswell, but I just assumed you wanted the font through some interesting perspective view. Now that I think about it it is kind of sad this node do not have a camera input. That's why I offered the post script as a solution. Anyway, glad you found your solution Tim

Share this post

Link to post

Share on other sites

If you're using the Font COP, it generates a very small image inside a crop region on its own (Shift+LMB drag in the viewer to see it). If you export to a format that supports data windows like EXR or PIC, this will be preserved.