Jump to: Board index » General » Fusion

Cropping and adding a border to an image

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline
User avatar

John Epton

  • Posts: 132
  • Joined: Wed Nov 12, 2014 1:44 pm
  • Location: Orpington, Kent, UK

Cropping and adding a border to an image

PostTue Jan 23, 2018 1:05 pm

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
Resolve Studio 18 Fusion Studio 18 Desktop Video 12.1
Apple Mac M1 Studio
64 GB Memory
10 Cores
32c GPU
Disc 1 TB
BMD Speed Editor
Offline

Sander de Regt

  • Posts: 3565
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Cropping and adding a border to an image

PostTue Jan 23, 2018 1:12 pm

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?
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline
User avatar

John Epton

  • Posts: 132
  • Joined: Wed Nov 12, 2014 1:44 pm
  • Location: Orpington, Kent, UK

Re: Cropping and adding a border to an image

PostTue Jan 23, 2018 1:25 pm

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
Resolve Studio 18 Fusion Studio 18 Desktop Video 12.1
Apple Mac M1 Studio
64 GB Memory
10 Cores
32c GPU
Disc 1 TB
BMD Speed Editor
Offline

Sander de Regt

  • Posts: 3565
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Cropping and adding a border to an image

PostTue Jan 23, 2018 1:39 pm

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.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline
User avatar

John Epton

  • Posts: 132
  • Joined: Wed Nov 12, 2014 1:44 pm
  • Location: Orpington, Kent, UK

Re: Cropping and adding a border to an image

PostTue Jan 23, 2018 2:33 pm

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.
Resolve Studio 18 Fusion Studio 18 Desktop Video 12.1
Apple Mac M1 Studio
64 GB Memory
10 Cores
32c GPU
Disc 1 TB
BMD Speed Editor
Offline

Sander de Regt

  • Posts: 3565
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Cropping and adding a border to an image

PostTue Jan 23, 2018 3:24 pm

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.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline
User avatar

Bryan Ray

  • Posts: 2485
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Cropping and adding a border to an image

PostTue Jan 23, 2018 6:40 pm

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"
}
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline
User avatar

John Epton

  • Posts: 132
  • Joined: Wed Nov 12, 2014 1:44 pm
  • Location: Orpington, Kent, UK

Re: Cropping and adding a border to an image

PostWed Jan 24, 2018 7:05 pm

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
Resolve Studio 18 Fusion Studio 18 Desktop Video 12.1
Apple Mac M1 Studio
64 GB Memory
10 Cores
32c GPU
Disc 1 TB
BMD Speed Editor

Return to Fusion

Who is online

Users browsing this forum: No registered users and 23 guests