Jump to content

crop empty space around generated text


a41b

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.

Thanks.

Edited by a41b
Link to comment
Share on other sites

11 hours ago, kleer001 said:

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 :D

Link to comment
Share on other sites

1 hour ago, Butachan said:

I know you want to do it in the comp context but if the objective is to get a final image you may want to check this:

http://www.sidefx.com/docs/houdini/ref/utils/iautocrop.html

Hope it helps.

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.

Link to comment
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?).

Link to comment
Share on other sites

22 hours ago, a41b said:

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.

Link to comment
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.

Edited by a41b
Link to comment
Share on other sites

8 minutes ago, a41b said:

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 :) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...