Rendering Text From Metadata Tags

User avatar
AndrewHazelden
Fusionator
Posts: 1532
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 8
Location: West Dover, Nova Scotia, Canada
Been thanked: 100 times
Contact:

Rendering Text From Metadata Tags

#1

Post by AndrewHazelden » Wed Sep 06, 2017 1:23 pm

TextFromMetadata-viewer.png
This example shows how a Text+ node can be made to wirelesssly render metadata information from a Loader node in your composite. You can change the data source on the Text+ node by dragging and dropping a new Loader node onto the Text+ node's UserControl based "MetadataSource" attribute (that is visible on the Text Tab).
TextFromMetadata-drag-and-drop-connection.png
Download the Comp:
TextFromMetadata.comp
The Resize and Crop nodes are added to this example so the Loader node based images will be automatically sized and centered to fit in the view as you load in different pictures while testing the metadata tags.
TextFromMetadata-flow.png
How does this process work?

This example works because the Text+ node has a custom a UserControl input pasted on the end of the the node's code block named "MetadataSource":

Code: Select all

UserControls = ordered() {
  MetadataSource = {
    LINKID_DataType = "Image",
    INP_Default = 0,
    IC_ControlPage = 1,
    INPID_InputControl = "ImageControl",
    LINKS_Name = "MetadataSource",
  }
}
The Text+ Styled Text field then has an expression added that reads the wireless source connection and looks up a specific metadata tag. In this case it is a "Filename" Metadata attribute but you could change the expression to print out any other tag you want to display.

Expression:

Code: Select all

Text(self:GetSourceTool("MetadataSource").Output.Metadata.Filename)
If you wanted to print out the connected node name (like "Loader1") you could change the expression to:

Code: Select all

Text(self:GetSourceTool("MetadataSource").Name)
In the Viewer window you can click on the button labeled "SubV" and select the "Metadata" option in the menu to display a viewer window based overlay that shows of all the Metadata tags that are embedded in the current image. Any of these tags could be accessed from the Text+ node's Styled Text Expression.
fusion-viewer-subv-metadata.png
This workflow was inspired by Kristof's "Custom MainInputs" thread.
You do not have the required permissions to view the files attached to this post.

Tags:

User avatar
AndrewHazelden
Fusionator
Posts: 1532
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 8
Location: West Dover, Nova Scotia, Canada
Been thanked: 100 times
Contact:

Re: Rendering Text From Metadata Tags

#2

Post by AndrewHazelden » Thu Sep 07, 2017 4:40 am

This example builds on the technique from the previous post to show how you can overlay EXIF photographic metadata over the image. It depends on your imagery actually having EXIF metadata tags so you don't get an error in the Console tab.
fusion-viewer-metadata.png
Downloads:

Here is a Fusion comp example and a sample photo. If you save the two assets to the same folder, when you open the comp in Fusion the photo is automatically loaded in to the comp file using the relative Pathmap address of "Comp:/Two Chicken Feet Walking on a Keyboard.jpg".
TextFromPhotoMetadata.comp
Two Chicken Feet Walking on a Keyboard.jpg
The Styled Text Field then uses an expression added that reads the source connection and looks up a specific metadata tag. In this case it is the standard EXIF Metadata attributes but you could change it to print out any attribute you want to display.

Code: Select all

Text("[Camera] " .. self:GetSourceTool("MetadataSource").Output.Metadata.Camera.Make ..  " " .. self:GetSourceTool("MetadataSource").Output.Metadata.Camera.Model .. "\n" ..
"[ISO] " .. self:GetSourceTool("MetadataSource").Output.Metadata.Camera.Exif.PhotographicSensitivity .. "\n" ..
"[Focal Length] " .. self:GetSourceTool("MetadataSource").Output.Metadata.Camera.Exif.FocalLength .. " mm\n" ..
"[Shutter Speed] 1/" .. 1/self:GetSourceTool("MetadataSource").Output.Metadata.Camera.Exif.ExposureTime .. " th of a second\n" ..
"[F-Stop] " .. self:GetSourceTool("MetadataSource").Output.Metadata.Camera.Exif.FNumber .. "\n" )
With the sample image this will generate a text output of:
[Camera] SONY ILCE-7SM2
[ISO] 1600
[Focal Length] 0 mm
[Shutter Speed] 1/45 th of a second
[F-Stop] 0
Note: The F-Stop and FocalLength EXIF attributes are empty in this sample image since the photo was taken using a lens that was connected to a Sony A7SII camera with a purely mechanical lens adapter with no electronic lens data connections.

The Text+ node's image width and height settings are configured using these expressions:

Width:

Code: Select all

self:GetSourceTool("MetadataSource").Output.OriginalWidth
Height:

Code: Select all

self:GetSourceTool("MetadataSource").Output.OriginalHeight
fusion-auto-image-size.png
Note: You may need to nudge the Text+ node's Layout Tab > Center X/Y placement controls when you load your own image into the comp.
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 3774
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 7
Location: Vancouver, Canada
Been thanked: 146 times
Contact:

Re: Rendering Text From Metadata Tags

#3

Post by SecondMan » Sat Oct 14, 2017 8:21 pm

You write fantastic posts Andrew, thank you!

User avatar
AndrewHazelden
Fusionator
Posts: 1532
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 8
Location: West Dover, Nova Scotia, Canada
Been thanked: 100 times
Contact:

Re: Rendering Text From Metadata Tags

#4

Post by AndrewHazelden » Sun Oct 15, 2017 2:48 am

SecondMan wrote:You write fantastic posts Andrew, thank you!
Thanks SecondMan! That means a lot to me coming from you. :)