Skip to content

Commit

Permalink
#808 fixed detecting motion photos with more items in the XMP container
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerst committed Nov 10, 2023
1 parent 70a76c4 commit 83edd91
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ object MultiPage {
} else if (xmpMeta.doesPropExist(XMP.GCONTAINER_DIRECTORY_PROP_NAME)) {
// `Container` motion photo
val count = xmpMeta.countPropArrayItems(XMP.GCONTAINER_DIRECTORY_PROP_NAME)
if (count == 2) {
// expect the video to be the second item
val i = 2
for (i in 1 until count + 1) {
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
if (MimeTypes.isVideo(mime) && length != null) {
Expand Down
18 changes: 8 additions & 10 deletions android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,15 @@ object XMP {
// Container motion photo
if (doesPropExist(GCONTAINER_DIRECTORY_PROP_NAME)) {
val count = countPropArrayItems(GCONTAINER_DIRECTORY_PROP_NAME)
if (count == 2) {
var hasImage = false
var hasVideo = false
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 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
hasVideo = hasVideo || MimeTypes.isVideo(mime) && length != null
}
if (hasImage && hasVideo) return true
var hasImage = false
var hasVideo = false
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 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
hasVideo = hasVideo || MimeTypes.isVideo(mime) && length != null
}
if (hasImage && hasVideo) return true
}

return false
Expand Down
1 change: 1 addition & 0 deletions lib/ref/metadata/xmp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class XmpNamespaces {
static const gettyImagesGift = 'http://xmp.gettyimages.com/gift/1.0/';
static const gimp210 = 'http://www.gimp.org/ns/2.10/';
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 iptc4xmpCore = 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/';
static const iptc4xmpExt = 'http://iptc.org/std/Iptc4xmpExt/2008-02-29/';
Expand Down
1 change: 1 addition & 0 deletions lib/view/src/xmp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class XmpNamespaceView {
XmpNamespaces.gettyImagesGift: 'Getty Images',
XmpNamespaces.gimp210: 'GIMP 2.10',
XmpNamespaces.gimpXmp: 'GIMP',
XmpNamespaces.hdrgm: 'HDR Gain Map',
XmpNamespaces.illustrator: 'Illustrator',
XmpNamespaces.iptc4xmpCore: 'IPTC Core',
XmpNamespaces.iptc4xmpExt: 'IPTC Extension',
Expand Down

0 comments on commit 83edd91

Please sign in to comment.