News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Question about Charset Latin

Started by RicardoLand, October 18, 2018, 01:23:21 PM

Previous topic - Next topic

RicardoLand

Hi all,

I have a photo. If i use the command below i can see all the accents of the Caption-Abstract

exiftool -Caption-Abstract -L teste.jpg

I tried:
%option="";
$exifTool2 = new Image::ExifTool;
$option{'charsetIPTC'}="UTF8";
$option{'charset'}="UTF8";
$status=$exifTool2->ExtractInfo(FILE,\%option);
$caption = $exifTool2->GetValue("Caption-Abstract","PrintConv"); 
print $caption

I cant see the accents.

Any ideas?
Regards
Land


Phil Harvey

Hi Land,

The Charset option must also be applied during GetInfo() (as mentioned in the GetInfo documentation).

Also, your command was using the -L (Latin) character set.

So your command corresponds to this code:

$exifTool2 = new Image::ExifTool;
$exifTool2->Options(Charset => 'Latin');
$status = $exifTool2->ExtractInfo(FILE);
$caption = $exifTool2->GetValue("Caption-Abstract","PrintConv"); 
print $caption


- 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

Sorry. I copied the wrong code. The code below still doesnt return Latin chars.

Code:
I used:
%option="";
$exifTool2 = new Image::ExifTool;
$option{'charsetIPTC'}="Latin";
$option{'charset'}="Latin";
$status=$exifTool2->ExtractInfo(FILE,\%option);
$caption = $exifTool2->GetValue("Caption-Abstract","PrintConv"); 
print $caption

In my code i have two variables. Any problem ?
$exifTool = new Image::ExifTool;   --> charset UTF8
$exifTool2 = new Image::ExifTool; --> charset Latin

Phil Harvey

... and it shouldn't.

If the IPTC and the ExifTool character sets are the same then no translation is done and you'll see whatever encoding was used to store the tags (which apparently isn't 'Latin', or you would be getting Latin characters).  So setting CharsetIPTC to 'Latin' is wrong.  Try setting this to 'UTF8' (although this shouldn't be necessary for your example file since the command line worked without setting this).

Did you try the code I posted?

Also, did you read FAQ 10?

There is no problem having two ExifTool objects with different options.

- 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 to be so friend !!!!

I have a challenge here to correct some accents in the photos. The photos are from an old system and as far as i know they are not Latin or UTF-8. I dont know what encode are used but i guess a way to correct them but it is very strange.

I am using putty with UTF-8 configuration. When i use    exiftool -Caption-abstract foleto7.jpg i dont see the accents. When i use exiftool -Caption-abstract foleto7.jpg i dont see the accents too. So i think the characters are not Latin or UTF-8.

i made some tests. If i use the command below i can see the accents. I dont know a reason to use decode.
$caption = decode("utf-8", $caption);
print $caption

But it solves my problem. If i can write this value to the iptc tag my problem is solved.

I tried $exifTool->SetNewValue("Caption-Abstract",$caption,{Replace=>1});

But the $caption variable is not written as see in the screen.

Any ideas ?

Regards
Land



Phil Harvey

Hi Land,

I think you want this:

$exifTool2 = new Image::ExifTool;
$exifTool2->Options(Charset => 'Latin');
$exifTool2->Options(IPTCCharset => 'UTF8');
$status = $exifTool2->ExtractInfo(FILE);
$caption = $exifTool2->GetValue("Caption-Abstract","PrintConv"); 
print $caption


This will convert a caption stored as UTF-8 to Latin for printing.

- 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,

It solved all my problems.

Loved this line :-)))
$exifTool2->Options(IPTCCharset => 'UTF8');

Thanks a lot
Regards
Land