Convert IPTC values to a different internal encoding using exiftool

Started by RicardoLand, March 19, 2019, 05:28:28 PM

Previous topic - Next topic

RicardoLand

Hi all,

I have a file (jpg file) that have a problem in its iptc encondig. In this file, the iptc field codedcharacterset is set to UTF-8. But the internal iptc fields such as Caption-Description are set to Latin. I manage to read the fields with the -L option. But i want to convert the fields to UTF-8

I tried the command below as described in the manual. But it didnt work as the CodedCharacterSet is already "UTF8". I manage to do this with some programing with Image::ExifTool, but not so simple. Well, is there a way to force this transformation ?

Command:
exiftool -tagsfromfile @ -iptc:all -codedcharacterset=utf8 a.jpg

Thanks
Land

Phil Harvey

It sounds like you should do exiftool -codedcharacterset= FILE to remove the invalid CodedCharacterSet, then run your command to recode the IPTC and set CodedCharacterSet to UTF8.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

RicardoLand

Hi Phil,
Thanks for your answer.

I had tried it without sucess.

a)
exiftool -codedcharacterset= aaa.jpg
Warning: [Minor] IPTC doesn't conform to spec: Records out of sequence - aaa.jpg (maybe another problem)
    0 image files updated
    1 image files unchanged

b)
exiftool -m -codedcharacterset= aaa.jpg
1 image files updated
exiftool -tagsfromfile @ -iptc:all -codedcharcterset=utf8 aaa.jpg
1 image files updated

No sucess

My Solution (not so simple, but ....)
With Image::ExifTool

$exifTool->ExtractInfo($arqEntrada);    --> Reading as UTF-8

$exifTool2->Options(Charset => 'Latin'); --> Reading as Lating
$captionANSI = $exifTool2->GetValue("Caption-Abstract","PrintConv"); 

$exifTool->SetNewValue("Caption-Abstract",$captionANSI,{Replace=>1}); --> Writing Latin in photo even codedcharacterset is UTF-8

After that i did with command line
exiftool -tagsfromfile @ -iptc:all -codedcharacterset=utf8 a.jpg

And this work OK (for Caption-Abstract). Now IPTC is Latin.

Any ideas what is happening ?

Thanks again !!
Land



Phil Harvey

The IPTC in the file you posted is coded in UTF-8 (not Latin), but since the records are out of sequence, the CodedCharacterSet isn't applied to some fields.

So just doing this should fix things:

1. exiftool -codedcharacterset= -m aaa.jpg

2. exiftool -codedcharacterset=utf8 aaa.jpg

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

RicardoLand

Hi Phil,

you are right.

I sent you the wrong photo (it was in my development enviroment). Sending it again only if someone else read this topic.

The code worked. I was trying to do it in only one line....

1. exiftool -codedcharacterset= -m aaa.jpg
2. exiftool -codedcharacterset=utf8 aaa.jpg



Thanks to be so friend
Land


Phil Harvey

Hi Land,

Yeah.  Doing it in one command won't work because ExifTool would rewrite the existing CodedCharacterSet record in the same (incorrect) location.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).