#808 fixed detecting motion photos with more items in the XMP container

This commit is contained in:
Thibault Deckers 2023-11-10 21:53:44 +01:00
parent 70a76c4f56
commit 83edd91f39
4 changed files with 11 additions and 13 deletions

View file

@ -174,9 +174,7 @@ object MultiPage {
} else if (xmpMeta.doesPropExist(XMP.GCONTAINER_DIRECTORY_PROP_NAME)) { } else if (xmpMeta.doesPropExist(XMP.GCONTAINER_DIRECTORY_PROP_NAME)) {
// `Container` motion photo // `Container` motion photo
val count = xmpMeta.countPropArrayItems(XMP.GCONTAINER_DIRECTORY_PROP_NAME) val count = xmpMeta.countPropArrayItems(XMP.GCONTAINER_DIRECTORY_PROP_NAME)
if (count == 2) { for (i in 1 until count + 1) {
// expect the video to be the second item
val i = 2
val mime = xmpMeta.getSafeStructField(listOf(XMP.GCONTAINER_DIRECTORY_PROP_NAME, i, XMP.GCONTAINER_ITEM_PROP_NAME, XMP.GCONTAINER_ITEM_MIME_PROP_NAME))?.value val mime = xmpMeta.getSafeStructField(listOf(XMP.GCONTAINER_DIRECTORY_PROP_NAME, i, XMP.GCONTAINER_ITEM_PROP_NAME, XMP.GCONTAINER_ITEM_MIME_PROP_NAME))?.value
val length = xmpMeta.getSafeStructField(listOf(XMP.GCONTAINER_DIRECTORY_PROP_NAME, i, XMP.GCONTAINER_ITEM_PROP_NAME, XMP.GCONTAINER_ITEM_LENGTH_PROP_NAME))?.value val length = xmpMeta.getSafeStructField(listOf(XMP.GCONTAINER_DIRECTORY_PROP_NAME, i, XMP.GCONTAINER_ITEM_PROP_NAME, XMP.GCONTAINER_ITEM_LENGTH_PROP_NAME))?.value
if (MimeTypes.isVideo(mime) && length != null) { if (MimeTypes.isVideo(mime) && length != null) {

View file

@ -188,17 +188,15 @@ object XMP {
// Container motion photo // Container motion photo
if (doesPropExist(GCONTAINER_DIRECTORY_PROP_NAME)) { if (doesPropExist(GCONTAINER_DIRECTORY_PROP_NAME)) {
val count = countPropArrayItems(GCONTAINER_DIRECTORY_PROP_NAME) val count = countPropArrayItems(GCONTAINER_DIRECTORY_PROP_NAME)
if (count == 2) { var hasImage = false
var hasImage = false var hasVideo = false
var hasVideo = false for (i in 1 until count + 1) {
for (i in 1 until count + 1) { val mime = getSafeStructField(listOf(GCONTAINER_DIRECTORY_PROP_NAME, i, GCONTAINER_ITEM_PROP_NAME, GCONTAINER_ITEM_MIME_PROP_NAME))?.value
val mime = getSafeStructField(listOf(GCONTAINER_DIRECTORY_PROP_NAME, i, GCONTAINER_ITEM_PROP_NAME, GCONTAINER_ITEM_MIME_PROP_NAME))?.value val length = getSafeStructField(listOf(GCONTAINER_DIRECTORY_PROP_NAME, i, GCONTAINER_ITEM_PROP_NAME, GCONTAINER_ITEM_LENGTH_PROP_NAME))?.value
val length = getSafeStructField(listOf(GCONTAINER_DIRECTORY_PROP_NAME, i, GCONTAINER_ITEM_PROP_NAME, GCONTAINER_ITEM_LENGTH_PROP_NAME))?.value hasImage = hasImage || MimeTypes.isImage(mime) && length != null
hasImage = hasImage || MimeTypes.isImage(mime) && length != null hasVideo = hasVideo || MimeTypes.isVideo(mime) && length != null
hasVideo = hasVideo || MimeTypes.isVideo(mime) && length != null
}
if (hasImage && hasVideo) return true
} }
if (hasImage && hasVideo) return true
} }
return false return false

View file

@ -37,6 +37,7 @@ class XmpNamespaces {
static const gettyImagesGift = 'http://xmp.gettyimages.com/gift/1.0/'; static const gettyImagesGift = 'http://xmp.gettyimages.com/gift/1.0/';
static const gimp210 = 'http://www.gimp.org/ns/2.10/'; static const gimp210 = 'http://www.gimp.org/ns/2.10/';
static const gimpXmp = 'http://www.gimp.org/xmp/'; static const gimpXmp = 'http://www.gimp.org/xmp/';
static const hdrgm = 'http://ns.adobe.com/hdr-gain-map/1.0/';
static const illustrator = 'http://ns.adobe.com/illustrator/1.0/'; static const illustrator = 'http://ns.adobe.com/illustrator/1.0/';
static const iptc4xmpCore = 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'; static const iptc4xmpCore = 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/';
static const iptc4xmpExt = 'http://iptc.org/std/Iptc4xmpExt/2008-02-29/'; static const iptc4xmpExt = 'http://iptc.org/std/Iptc4xmpExt/2008-02-29/';

View file

@ -34,6 +34,7 @@ class XmpNamespaceView {
XmpNamespaces.gettyImagesGift: 'Getty Images', XmpNamespaces.gettyImagesGift: 'Getty Images',
XmpNamespaces.gimp210: 'GIMP 2.10', XmpNamespaces.gimp210: 'GIMP 2.10',
XmpNamespaces.gimpXmp: 'GIMP', XmpNamespaces.gimpXmp: 'GIMP',
XmpNamespaces.hdrgm: 'HDR Gain Map',
XmpNamespaces.illustrator: 'Illustrator', XmpNamespaces.illustrator: 'Illustrator',
XmpNamespaces.iptc4xmpCore: 'IPTC Core', XmpNamespaces.iptc4xmpCore: 'IPTC Core',
XmpNamespaces.iptc4xmpExt: 'IPTC Extension', XmpNamespaces.iptc4xmpExt: 'IPTC Extension',