All Downloads are FREE. Search and download functionalities are using the official Maven repository.

posixMain.com.ashampoo.xmp.Main.kt Maven / Gradle / Ivy

package com.ashampoo.xmp

import com.ashampoo.xmp.options.SerializeOptions
import platform.posix.perror

private val xmpSerializeOptionsCompact =
    SerializeOptions()
        .setOmitXmpMetaElement(false)
        .setOmitPacketWrapper(false)
        .setUseCompactFormat(true)
        .setUseCanonicalFormat(false)
        .setSort(true)

fun main(args: Array) {

    if (args.size != 1) {
        println("USAGE: Must be called with one argument.")
        return
    }

    val filePath = args.first()

    val bytes = readFileAsByteArray(filePath)

    if (bytes == null) {
        perror("File could not be read: $filePath")
        return
    }

    val xmp = bytes.decodeToString()

    val xmpMeta = XMPMetaFactory.parseFromString(xmp)

    val newXmp = XMPMetaFactory.serializeToString(xmpMeta, xmpSerializeOptionsCompact)

    println(newXmp)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy