diff --git a/README.md b/README.md
index 0a655e1..a2ede93 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# XMP Core for Kotlin Multiplatform
-[](httpw://kotlinlang.org)
+[](httpw://kotlinlang.org)



@@ -20,7 +20,7 @@ It's part of [Ashampoo Photo Organizer](https://ashampoo.com/photo-organizer).
## Installation
```
-implementation("com.ashampoo:xmpcore:1.5.0")
+implementation("com.ashampoo:xmpcore:1.5.1")
```
## How to use
diff --git a/build.gradle.kts b/build.gradle.kts
index a5f56f0..be23d86 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
- kotlin("multiplatform") version "2.1.0"
+ kotlin("multiplatform") version "2.1.10"
id("com.android.library") version "8.5.0"
id("maven-publish")
id("signing")
@@ -295,7 +295,7 @@ android {
namespace = "com.ashampoo.xmpcore"
- compileSdk = 34
+ compileSdk = 35
sourceSets["main"].res.srcDirs("src/commonMain/resources")
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 18362b7..9bf7bd3 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt b/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
index bed32fc..3574932 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
@@ -2018,7 +2018,7 @@ public class XMPMeta internal constructor() {
}
/*
- * For missing values fall back to the Photoshop namespace.
+ * For missing values fall back to older places.
*/
if (location.isNullOrBlank())
@@ -2062,13 +2062,21 @@ public class XMPMeta internal constructor() {
xmpLocation: XMPLocation?
) {
- /* Delete existing entries, if any */
+ /* Delete existing entries */
+
deleteProperty(XMPConst.NS_IPTC_EXT, XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN)
+ deleteProperty(XMPConst.NS_IPTC_CORE, "Location")
+ deleteProperty(XMPConst.NS_PHOTOSHOP, "City")
+ deleteProperty(XMPConst.NS_PHOTOSHOP, "State")
+ deleteProperty(XMPConst.NS_PHOTOSHOP, "Country")
if (xmpLocation == null)
return
- /* Create a new array property. */
+ /*
+ * Write Iptc4xmpExt:LocationShown
+ */
+
setProperty(
XMPConst.NS_IPTC_EXT,
XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN,
@@ -2076,7 +2084,6 @@ public class XMPMeta internal constructor() {
arrayOptions
)
- /* Append empty entry */
appendArrayItem(
schemaNS = XMPConst.NS_IPTC_EXT,
arrayName = XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN,
@@ -2112,8 +2119,7 @@ public class XMPMeta internal constructor() {
)
}
- if (!xmpLocation.location.isNullOrBlank()) {
-
+ if (!xmpLocation.location.isNullOrBlank())
setStructField(
schemaNS = XMPConst.NS_IPTC_EXT,
structName = XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN + "[1]",
@@ -2122,15 +2128,7 @@ public class XMPMeta internal constructor() {
fieldValue = xmpLocation.location
)
- setProperty(
- schemaNS = XMPConst.NS_IPTC_CORE,
- propName = "Location",
- propValue = xmpLocation.location
- )
- }
-
- if (!xmpLocation.city.isNullOrBlank()) {
-
+ if (!xmpLocation.city.isNullOrBlank())
setStructField(
schemaNS = XMPConst.NS_IPTC_EXT,
structName = XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN + "[1]",
@@ -2139,15 +2137,7 @@ public class XMPMeta internal constructor() {
fieldValue = xmpLocation.city
)
- setProperty(
- schemaNS = XMPConst.NS_PHOTOSHOP,
- propName = "City",
- propValue = xmpLocation.city
- )
- }
-
- if (!xmpLocation.state.isNullOrBlank()) {
-
+ if (!xmpLocation.state.isNullOrBlank())
setStructField(
schemaNS = XMPConst.NS_IPTC_EXT,
structName = XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN + "[1]",
@@ -2156,15 +2146,7 @@ public class XMPMeta internal constructor() {
fieldValue = xmpLocation.state
)
- setProperty(
- schemaNS = XMPConst.NS_PHOTOSHOP,
- propName = "State",
- propValue = xmpLocation.state
- )
- }
-
- if (!xmpLocation.country.isNullOrBlank()) {
-
+ if (!xmpLocation.country.isNullOrBlank())
setStructField(
schemaNS = XMPConst.NS_IPTC_EXT,
structName = XMPConst.XMP_IPTC_EXT_LOCATION_SHOWN + "[1]",
@@ -2173,12 +2155,21 @@ public class XMPMeta internal constructor() {
fieldValue = xmpLocation.country
)
- setProperty(
- schemaNS = XMPConst.NS_PHOTOSHOP,
- propName = "Country",
- propValue = xmpLocation.country
- )
- }
+ /*
+ * Write older fields for completeness
+ */
+
+ if (!xmpLocation.location.isNullOrBlank())
+ setProperty(XMPConst.NS_IPTC_CORE, "Location", xmpLocation.location)
+
+ if (!xmpLocation.city.isNullOrBlank())
+ setProperty(XMPConst.NS_PHOTOSHOP, "City", xmpLocation.city)
+
+ if (!xmpLocation.state.isNullOrBlank())
+ setProperty(XMPConst.NS_PHOTOSHOP, "State", xmpLocation.state)
+
+ if (!xmpLocation.country.isNullOrBlank())
+ setProperty(XMPConst.NS_PHOTOSHOP, "Country", xmpLocation.country)
}
public fun getTitle(): String? {
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/XMPVersionInfo.kt b/src/commonMain/kotlin/com/ashampoo/xmp/XMPVersionInfo.kt
index 54fbc40..d144690 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/XMPVersionInfo.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/XMPVersionInfo.kt
@@ -9,7 +9,7 @@ public object XMPVersionInfo {
public const val MAJOR: Int = 1
public const val MINOR: Int = 5
- public const val PATCH: Int = 0
+ public const val PATCH: Int = 1
public const val VERSION_MESSAGE: String =
"Ashampoo XMP Core $MAJOR.$MINOR.$PATCH"
diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/ReadXmpTest.kt b/src/commonTest/kotlin/com/ashampoo/xmp/ReadXmpTest.kt
index 9ad6d7d..5e5370d 100644
--- a/src/commonTest/kotlin/com/ashampoo/xmp/ReadXmpTest.kt
+++ b/src/commonTest/kotlin/com/ashampoo/xmp/ReadXmpTest.kt
@@ -222,8 +222,6 @@ class ReadXmpTest {
""".trimIndent()
- println(testXmp)
-
val xmpMeta = XMPMetaFactory.parseFromString(testXmp)
assertEquals(
diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt b/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt
index c73876b..7b4a9ec 100644
--- a/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt
+++ b/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt
@@ -412,6 +412,72 @@ class WriteXmpTest {
)
}
+ /**
+ * Create an XMP only containing location info.
+ */
+ @OptIn(ExperimentalStdlibApi::class)
+ @Test
+ fun testLocationRemovalXmp() {
+
+ /* language=XML */
+ val originalXmp = """
+
+
+
+
+
+
+
+
+
+
+ Ashampoo GmbH & Co. KG
+
+
+
+
+
+
+
+
+
+
+ """.trimIndent()
+
+ val xmpMeta = XMPMetaFactory.parseFromString(originalXmp)
+
+ xmpMeta.setLocation(null)
+
+ val actualXmp = XMPMetaFactory.serializeToString(xmpMeta, xmpSerializeOptionsCompact)
+
+ /* language=XML */
+ val expectedXmp = """
+
+
+
+
+
+
+
+ """.trimIndent()
+
+ assertEquals(
+ expected = expectedXmp,
+ actual = actualXmp
+ )
+ }
+
/**
* Create an XMP only containing title & description.
*/
@@ -429,7 +495,7 @@ class WriteXmpTest {
/* language=XML */
val expectedXmp = """
-
+
diff --git a/src/commonTest/resources/com/ashampoo/xmp/sample_100_formatted_canonical.xmp b/src/commonTest/resources/com/ashampoo/xmp/sample_100_formatted_canonical.xmp
index 3431fbc..1e592d1 100644
--- a/src/commonTest/resources/com/ashampoo/xmp/sample_100_formatted_canonical.xmp
+++ b/src/commonTest/resources/com/ashampoo/xmp/sample_100_formatted_canonical.xmp
@@ -1,5 +1,5 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/src/commonTest/resources/com/ashampoo/xmp/sample_13_formatted_compact.xmp b/src/commonTest/resources/com/ashampoo/xmp/sample_13_formatted_compact.xmp
index b4622b4..5286494 100644
--- a/src/commonTest/resources/com/ashampoo/xmp/sample_13_formatted_compact.xmp
+++ b/src/commonTest/resources/com/ashampoo/xmp/sample_13_formatted_compact.xmp
@@ -1,5 +1,5 @@
-
+
-
+
diff --git a/src/commonTest/resources/com/ashampoo/xmp/sample_14_formatted_compact.xmp b/src/commonTest/resources/com/ashampoo/xmp/sample_14_formatted_compact.xmp
index 2915d63..4064bf8 100644
--- a/src/commonTest/resources/com/ashampoo/xmp/sample_14_formatted_compact.xmp
+++ b/src/commonTest/resources/com/ashampoo/xmp/sample_14_formatted_compact.xmp
@@ -1,5 +1,5 @@
-
+
-
+
diff --git a/src/commonTest/resources/com/ashampoo/xmp/sample_15_formatted_compact.xmp b/src/commonTest/resources/com/ashampoo/xmp/sample_15_formatted_compact.xmp
index dfbd3ac..b5b88c2 100644
--- a/src/commonTest/resources/com/ashampoo/xmp/sample_15_formatted_compact.xmp
+++ b/src/commonTest/resources/com/ashampoo/xmp/sample_15_formatted_compact.xmp
@@ -1,5 +1,5 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+