Page 1 of 1

Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 1:05 pm
by John Epton
With most video editor effects it is possible to crop an image in from any of the four sides and add a user defined width border around the whole image. Like the white border around a photograph.
I cannot find a way of achieving this in Fusion unless I have access to the resultant height and width of the image.
Can any one suggest a solution to this fairly basic requirement?
Thanks
John Epton

Re: Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 1:12 pm
by Sander de Regt
There are so many ways to do this in Fusion I don't know where to start.
You say it's a basic requirement, but for what kind of purpose?
If you can do it in every video editor (which Fusion isn't) then what do you want to do in Fusion that you need this for? Can you give a specific example, so I can give you some specific advice?

Re: Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 1:25 pm
by John Epton
Sander
I have a map to show a journey.
A moving line on the map shows the various locations visited which are described in the narration.
The line stops at a location and a photograph of the location emerges from the location, zooming up from zero size to about 80% full screen. I want his photo to have a border. The photo shrinks back to the location.
There are lots of locations and the photos have different sizes and aspect ratios and some need cropping.

I can create a background and size and place the photo on the background at the correct size to form a border, however I wanted to create a macro to do it generically if possible.

Thanks
John Epton

Re: Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 1:39 pm
by Sander de Regt
Hi John,

You could probably do this in a macro without too much problem.
It depends on what kind of control you want/need. Do you need the border width to be in pixels or percentages etc.

With a couple of expressions and macro building, you should be done pretty quickly.
I am not a very good at creating expressions, but you could probably create a crop set to 'original width' and 'original height' so that it will always automatically adapt to the incoming image, create two custom integer sliders and use those in the expressions as well to drive the cropping. Merge that on top of a Bg tool in the color of your desired border. Create expressions in the width and height of the bg tool and link them to the crop values, and then create an integer slider (or 2) for the border thickness, this way you can have almost everything drive itself, while still maintaining control.

I hope this can get you started.

Re: Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 2:33 pm
by John Epton
Sander

I understand what you are saying apart from
"create a crop set to 'original width' and 'original height' ".

Is "original width" a readable attribute of an image? If so how can I access it? Especially when the image in question will be the one connected to the input of the macro?


Thanks
John
PS I will have to leave my pc shortly.

Re: Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 3:24 pm
by Sander de Regt
Yes, it is a readable attribute, but I don't remember right now what the exact expression is for it.
So I'll have to search for it in the manual. It's in there somewhere.
You can also check the forum at www.steakunderwater.com I'm pretty sure this topic has come up before, maybe they can help you quicker there.

Re: Cropping and adding a border to an image

PostPosted: Tue Jan 23, 2018 6:40 pm
by Bryan Ray
If you want the width and height of the incoming image:

self.Input.Width
self.Input.Height

And here's a sample node:

Code: Select all
{
   Tools = ordered() {
      Crop1 = Crop {
         CtrlWZoom = false,
         Inputs = {
            XOffset = Input { Value = -40, },
            YOffset = Input { Value = -40, },
            XSize = Input {
               Value = 1219,
               Expression = "self.Input.Width+wide",
            },
            YSize = Input {
               Value = 721,
               Expression = "self.Input.Height+high",
            },
            KeepCentered = Input { Value = 1, },
            wide = Input { Value = 81, },
            high = Input { Value = 81, }
         },
         ViewInfo = OperatorInfo { Pos = { 770, 49.5 } },
         UserControls = ordered() {
            wide = {
               LINKS_Name = "wide",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Default = 0,
               INP_Integer = true,
               INP_MinScale = -500,
               INP_MaxScale = 500,
               INP_MinAllowed = -1000000,
               INP_MaxAllowed = 1000000,
               ICS_ControlPage = "Cropping"
            },
            high = {
               LINKS_Name = "high",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Integer = true,
               INP_MinScale = -500,
               INP_MaxScale = 500,
               ICS_ControlPage = "Cropping"
            }
         }
      }
   },
   ActiveTool = "Crop1"
}

Re: Cropping and adding a border to an image

PostPosted: Wed Jan 24, 2018 7:05 pm
by John Epton
Bryan and Sander
Many thanks for responding so promptly and for giving me some great advice and the code.
I am now confident that I can build my macro.
As a final point, can you please recommend the best source of documentation for these types of expressions?
John Epton