I want to remove all the metadata of an image except "Copyright".I am using exiftool of this .The command for this is "exiftool -all= -tagsFromFile @ -copyright Tunis_Bab_Souika_1899.jpg".But when I do this in java application .It somehow deletes all the tags.
here is the code snippet -
val outputConsumer = ArrayListOutputConsumer()
val exiftoolCmd = ExiftoolCmd()
exiftoolCmd.setOutputConsumer(outputConsumer)
val operation = ETOperation()
println("File name" + sourceImage.toFile().absolutePath)
operation.addImage(sourceImage.toFile().absolutePath)
// exiftool -all= -tagsFromFile @ -copyright Tunis_Bab_Souika_1899.jpg
operation.addRawArgs("-all=")
operation.addRawArgs("-tagsFromFile @")
operation.addRawArgs("-copyright")
println("About to execute")
try {exiftoolCmd.run(operation)
println("Inside try")
} catch (e: java.lang.Exception) {
throw RuntimeException(e)
}
val output = outputConsumer.output
.stream()
.map { obj: String -> obj.trim { it <= ' ' } }
.collect(toList())
println("ooutput$output")
Answering my question - This worked for me-
operation.delTags("all")
operation.tagsFromFile("@")
operation.getTags("copyright")
operation.addImage(sourceImage.toFile().absolutePath)