Welcome to WSL!

New to the forum? Please read this and this.

Urgent auto cropping problem

Moderator: SecondMan

User avatar
Hiski
Posts: 9
Joined: Mon Dec 21, 2020 5:07 am

Urgent auto cropping problem

#1

Post by Hiski »

Hi!

I'm having a very stupid problem and I'm starting to feel like there's something I'm just missing here.

I've saved a .psd layer with a lot of layers in it. When I import that psd to Fusion, every layer has the same borders as the background. (in this case - 4096 x 4096)

The Crop-node has a nice auto crop function which does the trick and removes all unwanted space around layer's content but it centers the layer to the composition and therefore I'd need to move it back to it's original position. As I have a lot of layers, I'd like that to be automated.

I'm aware I can check the "Keep Centered" box but then it crops to center of the composition instead of layer content.

Is it me missing something or the Crop node? :?

User avatar
Midgardsormr
Fusionator
Posts: 2102
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 24
Location: Los Angeles, CA, USA
Been thanked: 23 times
Contact:

Re: Urgent auto cropping problem

#2

Post by Midgardsormr »

How would you expect Fusion to know the original position of a layer if you've removed the information that would tell it what that was (the raster size)? What is the result you're trying to achieve by cropping?

User avatar
Hiski
Posts: 9
Joined: Mon Dec 21, 2020 5:07 am

Re: Urgent auto cropping problem

#3

Post by Hiski »

Thanks for your reply, Brian!

I understand. Would there be any ways to achieve this though? If I had hundreds of layers, cropping them and then moving them back to their positions would be a huge amount work.

User avatar
ShadowMaker SdR
Fusionator
Posts: 1065
Joined: Sun Sep 21, 2014 6:17 am
Answers: 10
Been thanked: 16 times

Re: Urgent auto cropping problem

#4

Post by ShadowMaker SdR »

I think Bryan is asking why you need to do the auto cropping (which basically means removing nothing) and then put it back in place. What are you hoping to gain by doing this?

User avatar
Hiski
Posts: 9
Joined: Mon Dec 21, 2020 5:07 am

Re: Urgent auto cropping problem

#5

Post by Hiski »

First, sorry if I'm being unclear. I'm in middle of a process of moving from After Effects to Fusion and some things are a little unclear for me. In other words - I'm a newbie.

The things I'm trying to gain by auto cropping the empty borders off are:

1. The pivot would go in the middle of (cropped) layer content automatically. There would be no need to move it by hand.

2. If I had, let's say, 1000 layers, selected layers would be more readable if the layers' borders were around the content instead of the original canvas.

I attached an image from After Effects where you can see how I'd like the imported psd layers to look like border-wise.
WhatsApp Image 2021-01-15 at 10.14.20.jpeg
You do not have the required permissions to view the files attached to this post.

User avatar
ShadowMaker SdR
Fusionator
Posts: 1065
Joined: Sun Sep 21, 2014 6:17 am
Answers: 10
Been thanked: 16 times

Re: Urgent auto cropping problem

#6

Post by ShadowMaker SdR »

So if you *want* to have the pivot in the center (which I understand) how does AE prevent the repositioning you're referring to? i.e. why isn't there a need to reposition the layers in AE, how does it handle them differently?

User avatar
intelligent machine
Fusionista
Posts: 737
Joined: Fri May 13, 2016 10:01 pm
Answers: 8
Location: Austin, Texas, USA
Real name: Sam Treadway
Been thanked: 12 times
Contact:

Re: Urgent auto cropping problem

#7

Post by intelligent machine »

It would be possible to add a button script to a macro containing a crop merged over a transparent BG by setting that BG to the original width of the Crop input, then position the merge over with the math below.

I may have a little time to work on this next week but here's the math that will take care of positioning the transform after the crop - you can't put this as the center expression as it will be locked that that position but using a button script is a one-time op to reposition it for further manipulation:

Point( ((1 / Crop1.Input.OriginalWidth * Crop1.XOffset) + (1 / Crop1.Input.OriginalWidth * Crop1.XSize / 2)), ((1 / Crop1.Input.OriginalHeight * Crop1.YOffset) + (1 / Crop1.Input.OriginalHeight * Crop1.YSize / 2)) )

User avatar
Midgardsormr
Fusionator
Posts: 2102
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 24
Location: Los Angeles, CA, USA
Been thanked: 23 times
Contact:

Re: Urgent auto cropping problem

#8

Post by Midgardsormr »

I was thinking it might be better to have a button script that would move the Pivot of a Transform to the center of the DoD, without cropping, but I seem to recall that there was a problem reading DoD from a script. I haven't gone back to see if that got sorted out.

User avatar
SirEdric
Fusionator
Posts: 2384
Joined: Tue Aug 05, 2014 10:04 am
Answers: 12
Real name: Eric Westphal
Been thanked: 4 times
Contact:

Re: Urgent auto cropping problem

#9

Post by SirEdric »

When using Transforms you could probably even go without cropping or scripts.
These XFs have an Expression on their pivot, moving the pivot to the center of the incoming DoD,
so you could scale & rotate around the DoD's Center.

Having many Expressions (as in 100 PSD Layers) notoriously slows things down a bit.
So if you don't need to animate the XF's, just a TimeStretcher to create a freeze frame of the incoming branches.

Code: Select all

{
	Tools = ordered() {
		Text1 = TextPlus {
			Inputs = {
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				Center = Input { Value = { 0.36150234741784, 0.583333333333333 }, },
				StyledText = Input { Value = "one", },
				Font = Input { Value = "Open Sans", },
				Style = Input { Value = "Bold", },
				VerticalJustificationNew = Input { Value = 3, },
				HorizontalJustificationNew = Input { Value = 3, },
				ManualFontKerningPlacement = Input {
					Value = StyledText {
						Array = {
						},
						Value = ""
					},
				},
			},
			ViewInfo = OperatorInfo { Pos = { -55, 16.5 } },
		},
		Transform1 = Transform {
			Inputs = {
				Pivot = Input {
					Value = { 0.361458333333333, 0.576851851851852 },
					Expression = "Point((self.Input.DataWindow[1]+(self.Input.DataWindow[3]-self.Input.DataWindow[1])/2)*HelperX, (self.Input.DataWindow[2]+(self.Input.DataWindow[4]-self.Input.DataWindow[2])/2)*HelperY)",
				},
				Input = Input {
					SourceOp = "Text1",
					Source = "Output",
				},
				HelperX = Input {
					Value = 0.000520833333333333,
					Expression = "1/self.Input.Width",
				},
				HelperY = Input {
					Value = 0.000925925925925926,
					Expression = "1/self.Input.Height",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 55, 16.5 } },
			UserControls = ordered() {
				HelperX = {
					LINKS_Name = "Helper X",
					LINKID_DataType = "Number",
					INPID_InputControl = "SliderControl",
					INP_Integer = false,
					ICS_ControlPage = "Controls"
				},
				HelperY = {
					LINKS_Name = "Helper Y",
					LINKID_DataType = "Number",
					INPID_InputControl = "SliderControl",
					INP_Integer = false,
					ICS_ControlPage = "Controls"
				}
			}
		},
		Text2 = TextPlus {
			Inputs = {
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				Center = Input { Value = { 0.21830985915493, 0.7375 }, },
				StyledText = Input { Value = "twothree", },
				Font = Input { Value = "Open Sans", },
				Style = Input { Value = "Bold", },
				VerticalJustificationNew = Input { Value = 3, },
				HorizontalJustificationNew = Input { Value = 3, },
				ManualFontKerningPlacement = Input {
					Value = StyledText {
						Array = {
						},
						Value = ""
					},
				},
			},
			ViewInfo = OperatorInfo { Pos = { -55, 49.5 } },
		},
		Transform1_1 = Transform {
			CtrlWZoom = false,
			Inputs = {
				Pivot = Input {
					Value = { 0.217708333333333, 0.739351851851852 },
					Expression = "Point((self.Input.DataWindow[1]+(self.Input.DataWindow[3]-self.Input.DataWindow[1])/2)*HelperX, (self.Input.DataWindow[2]+(self.Input.DataWindow[4]-self.Input.DataWindow[2])/2)*HelperY)",
				},
				Input = Input {
					SourceOp = "Text2",
					Source = "Output",
				},
				HelperX = Input {
					Value = 0.000520833333333333,
					Expression = "1/self.Input.Width",
				},
				HelperY = Input {
					Value = 0.000925925925925926,
					Expression = "1/self.Input.Height",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 55, 49.5 } },
			UserControls = ordered() {
				HelperX = {
					LINKS_Name = "Helper X",
					LINKID_DataType = "Number",
					INPID_InputControl = "SliderControl",
					INP_Integer = false,
					ICS_ControlPage = "Controls"
				},
				HelperY = {
					LINKS_Name = "Helper Y",
					LINKID_DataType = "Number",
					INPID_InputControl = "SliderControl",
					INP_Integer = false,
					ICS_ControlPage = "Controls"
				}
			}
		},
		TimeStretcher1 = TimeStretcher {
			Inputs = {
				SourceTime = Input { Value = 0, },
				InterpolateBetweenFrames = Input { Value = 0, },
				SampleSpread = Input { Disabled = true, },
				Input = Input {
					SourceOp = "Merge1",
					Source = "Output",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 330, 49.5 } },
		},
		Merge1 = Merge {
			Inputs = {
				Background = Input {
					SourceOp = "Transform1_1",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Transform1",
					Source = "Output",
				},
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 220, 49.5 } },
		}
	}
}

User avatar
intelligent machine
Fusionista
Posts: 737
Joined: Fri May 13, 2016 10:01 pm
Answers: 8
Location: Austin, Texas, USA
Real name: Sam Treadway
Been thanked: 12 times
Contact:

Re: Urgent auto cropping problem

#10

Post by intelligent machine »

SirEdric wrote: Sat Jan 16, 2021 3:12 amon their pivot, moving the pivot to the center of the incoming DoD
I get why you would want to default to the DoD but what I understand from the original post is that there are three asks:
1: to have the transform controls centered on the imported PSD layers
2: when selecting whatever tool will be used to manipulate those layers that the outlines that appear in the viewer are cropped to that layer's bounds and not the entire canvas
3: a way to automate this for each imported PSD layer.

This is just an example of the final outcome below but obviously there cannot be an expression on the transform control as it will not allow further manual manipulation within the viewer. The goal would be to create a script button that completes all the tasks in one easy step: invoke the auto crop action on that tool, then position the merge over to the layer's original location.

Code: Select all

{
	Tools = ordered() {
		Note1 = Note {
			CtrlWZoom = false,
			Inputs = {
				Comments = Input { Value = "View the Final Merge and select one of the prior merges. These merges would be contained in a Macro and when selecting that macro and pressing a single script button we'd have the same result.\n\nThis is why the OP wants the crop included", }
			},
			ViewInfo = StickyNoteInfo {
				Pos = { 440, 346.5 },
				Flags = {
					Expanded = true
				},
				Size = { 196, 79.5455 }
			},
		},
		Ellipse1 = EllipseMask {
			Inputs = {
				Filter = Input { Value = FuID { "Fast Gaussian" }, },
				MaskWidth = Input { Value = 2048, },
				MaskHeight = Input { Value = 1152, },
				PixelAspect = Input { Value = { 1, 1 }, },
				ClippingMode = Input { Value = FuID { "None" }, },
				Center = Input { Value = { 0.857291666666667, 0.214814814814815 }, },
				Width = Input { Value = 0.138200551233022, },
				Height = Input { Value = 0.138200551233022, },
			},
			ViewInfo = OperatorInfo { Pos = { 550, 49.5 } },
			Colors = {
				TileColor = { R = 0.474509803921569, G = 0.658823529411765, B = 0.815686274509804 },
				TextColor = { R = 0.474509803921569, G = 0.658823529411765, B = 0.815686274509804 },
			}
		},
		Background1 = Background {
			Inputs = {
				Width = Input { Value = 800, },
				Height = Input { Value = 600, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftRed = Input { Value = 1, },
				EffectMask = Input {
					SourceOp = "Ellipse1",
					Source = "Mask",
				}
			},
			ViewInfo = OperatorInfo { Pos = { 550, 82.5 } },
		},
		Merge2 = Merge {
			Inputs = {
				Background = Input {
					SourceOp = "TransparentBG",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Crop1",
					Source = "Output",
				},
				Center = Input { Expression = "Point( ((1 / Crop1.Input.OriginalWidth * Crop1.XOffset) + (1 / Crop1.Input.OriginalWidth * Crop1.XSize / 2)), ((1 / Crop1.Input.OriginalHeight * Crop1.YOffset) + (1 / Crop1.Input.OriginalHeight * Crop1.YSize / 2)) )", },
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 550, 280.5 } },
			Colors = {
				TileColor = { R = 0.886274509803922, G = 0.662745098039216, B = 0.109803921568627 },
				TextColor = { R = 0.725490196078431, G = 0.690196078431373, B = 0.592156862745098 },
			}
		},
		Merge2_2 = Merge {
			Inputs = {
				Background = Input {
					SourceOp = "Merge2",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Merge2_1",
					Source = "Output",
				},
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 660, 379.5 } },
			Colors = {
				TileColor = { R = 0.886274509803922, G = 0.662745098039216, B = 0.109803921568627 },
				TextColor = { R = 0.725490196078431, G = 0.690196078431373, B = 0.592156862745098 },
			}
		},
		TransparentBG = Background {
			NameSet = true,
			Inputs = {
				Width = Input {
					Value = 800,
					Expression = "Crop1.Input.OriginalWidth",
				},
				Height = Input {
					Value = 600,
					Expression = "Crop1.Input.OriginalHeight",
				},
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftAlpha = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 495, 214.5 } },
		},
		Crop1 = Crop {
			Inputs = {
				XOffset = Input { Value = 630, },
				YOffset = Input { Value = 73, },
				XSize = Input { Value = 112, },
				YSize = Input { Value = 112, },
				Input = Input {
					SourceOp = "Background1",
					Source = "Output",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 550, 181.5 } },
		},
		Merge2_1 = Merge {
			Inputs = {
				Background = Input {
					SourceOp = "TransparentBG_1",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Crop2",
					Source = "Output",
				},
				Center = Input { Expression = "Point( ((1 / Crop2.Input.OriginalWidth * Crop2.XOffset) + (1 / Crop2.Input.OriginalWidth * Crop2.XSize / 2)), ((1 / Crop2.Input.OriginalHeight * Crop2.YOffset) + (1 / Crop2.Input.OriginalHeight * Crop2.YSize / 2)) )", },
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 770, 280.5 } },
			Colors = {
				TileColor = { R = 0.886274509803922, G = 0.662745098039216, B = 0.109803921568627 },
				TextColor = { R = 0.725490196078431, G = 0.690196078431373, B = 0.592156862745098 },
			}
		},
		TransparentBG_1 = Background {
			NameSet = true,
			Inputs = {
				Width = Input {
					Value = 800,
					Expression = "Crop2.Input.OriginalWidth",
				},
				Height = Input {
					Value = 600,
					Expression = "Crop2.Input.OriginalHeight",
				},
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftAlpha = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 715, 214.5 } },
		},
		Crop2 = Crop {
			Inputs = {
				XOffset = Input { Value = 64, },
				YOffset = Input { Value = 150, },
				XSize = Input { Value = 192, },
				YSize = Input { Value = 198, },
				Input = Input {
					SourceOp = "Background1_1",
					Source = "Output",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 770, 181.5 } },
		},
		Background1_1 = Background {
			Inputs = {
				Width = Input { Value = 800, },
				Height = Input { Value = 600, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftGreen = Input { Value = 1, },
				EffectMask = Input {
					SourceOp = "Rectangle1",
					Source = "Mask",
				}
			},
			ViewInfo = OperatorInfo { Pos = { 770, 82.5 } },
		},
		Rectangle1 = RectangleMask {
			Inputs = {
				Filter = Input { Value = FuID { "Fast Gaussian" }, },
				MaskWidth = Input { Value = 2048, },
				MaskHeight = Input { Value = 1152, },
				PixelAspect = Input { Value = { 1, 1 }, },
				ClippingMode = Input { Value = FuID { "None" }, },
				Center = Input { Value = { 0.2, 0.414814814814815 }, },
				Width = Input { Value = 0.141518146551446, },
				Height = Input { Value = 0.27037037037037, },
				Angle = Input { Value = -41.1880168013597, },
			},
			ViewInfo = OperatorInfo { Pos = { 770, 49.5 } },
			Colors = {
				TileColor = { R = 0.474509803921569, G = 0.658823529411765, B = 0.815686274509804 },
				TextColor = { R = 0.474509803921569, G = 0.658823529411765, B = 0.815686274509804 },
			}
		},
		DoD_outline_shown_and_Transform_Centered = Underlay {
			NameSet = true,
			ViewInfo = UnderlayInfo {
				Pos = { 661.333, 247.5 },
				Size = { 498, 86 }
			},
			Colors = { TileColor = { R = 0.92156862745098, G = 0.431372549019608, B = 0 }, }
		},
		Macro = Underlay {
			NameSet = true,
			ViewInfo = UnderlayInfo {
				Pos = { 550, 148.5 },
				Size = { 207.333, 179.939 }
			},
		},
		Source_Layer_01 = Underlay {
			NameSet = true,
			ViewInfo = UnderlayInfo {
				Pos = { 550, 16.5 },
				Size = { 172, 102.97 }
			},
		},
		Macro_1 = Underlay {
			NameSet = true,
			ViewInfo = UnderlayInfo {
				Pos = { 770, 148.5 },
				Size = { 207.333, 179.939 }
			},
		},
		Source_Layer_02 = Underlay {
			NameSet = true,
			ViewInfo = UnderlayInfo {
				Pos = { 770, 16.5 },
				Size = { 172, 102.97 }
			},
		}
	},
	ActiveTool = "Note1"
}

User avatar
intelligent machine
Fusionista
Posts: 737
Joined: Fri May 13, 2016 10:01 pm
Answers: 8
Location: Austin, Texas, USA
Real name: Sam Treadway
Been thanked: 12 times
Contact:

Re: Urgent auto cropping problem

#11

Post by intelligent machine »

Here's the macro: :D
https://www.steakunderwater.com/wesuckl ... =45&t=4623

Please let me know if you find any bugs.

...and I'm completely open to other naming ideas.

User avatar
Hiski
Posts: 9
Joined: Mon Dec 21, 2020 5:07 am

Re: Urgent auto cropping problem

#12

Post by Hiski »

intelligent machine wrote: Sat Jan 16, 2021 10:21 pm Here's the macro: :D
https://www.steakunderwater.com/wesuckl ... =45&t=4623

Please let me know if you find any bugs.

...and I'm completely open to other naming ideas.
Not all heroes wear capes, some wear a bunch of code! Thank you very much for your help and time, sir!

User avatar
TerryPXM
Fusioneer
Posts: 81
Joined: Mon Oct 30, 2017 3:53 am
Location: Medellin, Colombia.

Re: Urgent auto cropping problem

#13

Post by TerryPXM »

This is really cool, I just tried myself because I couldn't understand what was doing and oh boy this does save some ass when working with layers from a .PSD.