Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Frameright app generated region metafields #16

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

klaari
Copy link
Contributor

@klaari klaari commented Oct 9, 2023

Include FramerightIdc:RegionDefinitionId and FramerightIdc:RegionName node values into the parsed ImageRegion

I have a use case where I wan't to be able to specify which region to use precisely.
For that I will need the regionDefinitionId and/or regionName genereated by the Frameright app.

Include FramerightIdc:RegionDefinitionId and FramerightIdc:RegionName
node values into the parsed ImageRegion
Copy link
Member

@lourot lourot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @klaari. This looks perfect. Just one nitpick

Comment on lines +385 to +388
$expectedRegion->regionDefinitionId = 'definition-7a54f275-6872-435e-befc-b52d97653a28';
$expectedRegion->regionName = '4:3 Horizontal';
$expectedRegion->id = 'crop-e789b6b8-ee15-45c0-a0c5-3ad38858db14';
$expectedRegion->names = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilu I'm surprised the IDC names bag is empty, instead of containing the same value as what we put in FramerightIdc:RegionName. Is this a bug in https://frameright.app ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test image I created with the https://frameright.app had the region name only in the FramerightIdc:RegionName
This is the full xmpmeta from the test file:

<x:xmpmeta
    xmlns:x="adobe:ns:meta/" x:xmptk="Frameright XMP Toolkit 2.0.0">
    <rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description
            xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/"
            xmlns:FramerightIdc="http://ns.frameright.io/idc/1.0/">
            <Iptc4xmpExt:ImageRegion
                xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/">
                <rdf:Bag>
                    <rdf:li rdf:parseType="Resource">
                        <Iptc4xmpExt:RegionBoundary rdf:parseType="Resource">
                            <Iptc4xmpExt:rbShape>rectangle</Iptc4xmpExt:rbShape>
                            <Iptc4xmpExt:rbUnit>relative</Iptc4xmpExt:rbUnit>
                            <Iptc4xmpExt:rbW>0.8890625</Iptc4xmpExt:rbW>
                            <Iptc4xmpExt:rbH>1</Iptc4xmpExt:rbH>
                            <Iptc4xmpExt:rbX>0.0375</Iptc4xmpExt:rbX>
                            <Iptc4xmpExt:rbY>0</Iptc4xmpExt:rbY>
                        </Iptc4xmpExt:RegionBoundary>
                        <Iptc4xmpExt:rId>crop-e789b6b8-ee15-45c0-a0c5-3ad38858db14</Iptc4xmpExt:rId>
                        <Iptc4xmpExt:rRole rdf:parseType="Resource">
                            <rdf:Bag>
                                <rdf:li rdf:parseType="Resource">
                                    <xmp:Identifier
                                        xmlns:xmp="http://ns.adobe.com/xap/1.0/">
                                        <rdf:Bag>
                                            <rdf:li>http://cv.iptc.org/newscodes/imageregionrole/cropping</rdf:li>
                                        </rdf:Bag>
                                    </xmp:Identifier>
                                </rdf:li>
                            </rdf:Bag>
                        </Iptc4xmpExt:rRole>
                        <FramerightIdc:RegionDefinitionId
                            xmlns:FramerightIdc="http://ns.frameright.io/idc/1.0/">definition-7a54f275-6872-435e-befc-b52d97653a28
                        </FramerightIdc:RegionDefinitionId>
                        <FramerightIdc:RegionName
                            xmlns:FramerightIdc="http://ns.frameright.io/idc/1.0/">4:3 Horizontal
                        </FramerightIdc:RegionName>
                    </rdf:li>
                </rdf:Bag>
            </Iptc4xmpExt:ImageRegion>
            <MetadataDate
                xmlns="http://ns.adobe.com/xap/1.0/">2023-10-08T06:53:22.336Z
            </MetadataDate>
            <ModifyDate
                xmlns="http://ns.adobe.com/xap/1.0/">2023-10-08T06:53:22.336Z
            </ModifyDate>
        </rdf:Description>
    </rdf:RDF>
</x:xmpmeta>```

Copy link
Member

@ilu ilu Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AurelienLourot It's more of an unimplemented feature. The FramerightIdc fields are intended for use with Frameright.app, so they have a bit different semantics than the Iptc4xmpExt:Name field. For example Iptc4xmpExt:Name needs to be unique and can have translations, both of which we would have to handle somehow on Frameright.app.

But yes, we should enable writing that field and some other fields as well in Frameright.app, but we need to figure out how to handle the ones that have conflicting semantics.

If the region has an existing Iptc4xmpExt:Name field (or any other fields), we leave them intact, and we only update the x, y, width, height, unit etc. fields and the FramerightIdc fields.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks for clarifying. @klaari this doesn't have any impact on this PR I was just curious

Comment on lines +120 to +122

'regionDefinitionId' => $region->regionDefinitionId,
'regionName' => $region->regionName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tempted to return these values only when $essentialOnly is false. Would this work for you @klaari? Thoughts @ilu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, works fine with me. I can do the update if we all agree?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me @AurelienLourot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klaari yes you can do the update, thanks a lot

@lourot lourot merged commit 457b8f7 into Frameright:master Oct 9, 2023
5 checks passed
@lourot
Copy link
Member

lourot commented Oct 9, 2023

Perfect, thanks a lot @klaari. Releasing v1.1.0 ...

@lourot
Copy link
Member

lourot commented Oct 9, 2023

done ✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants