Author Topic: Convert IPTC values to a different internal encoding using exiftool  (Read 216 times)

RicardoLand

  • Newbie
  • *
  • Posts: 9
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
« Last Edit: March 19, 2019, 06:06:37 PM by RicardoLand »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Convert IPTC values to a different internal encoding using exiftool
« Reply #1 on: March 19, 2019, 09:48:05 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

RicardoLand

  • Newbie
  • *
  • Posts: 9
Re: Convert IPTC values to a different internal encoding using exiftool
« Reply #2 on: March 20, 2019, 08:46:09 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Convert IPTC values to a different internal encoding using exiftool
« Reply #3 on: March 20, 2019, 08:57:55 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

RicardoLand

  • Newbie
  • *
  • Posts: 9
Re: Convert IPTC values to a different internal encoding using exiftool
« Reply #4 on: March 20, 2019, 09:12:23 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Convert IPTC values to a different internal encoding using exiftool
« Reply #5 on: March 20, 2019, 09:24:49 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).