Name of landmark in Google Earth displayed incorrectly

Started by babelfish, August 14, 2018, 11:32:05 AM

Previous topic - Next topic

babelfish

Hi,
I'm trying to converting a geo-tagged photo into kml file. I used a minor modified example kml.fmt file (see the attachment, the modificaiton is aim to  remove the .jpg part from filename):
exiftool -p kml.fmt  竹叶兰.jpg > test.kml

Although I have a warning (FileName encoding not specified - 竹叶兰.jpg), I have my kml file outputed. Google Eartch can open this file and display the landmark, but the name of
landmark is something unrecognizable!

I check a kml file which can be displayed correctly by GE, find it's name section is like this:
<name>&#31481;&#21494;&#20848;</name>

My kml is like this:
<name>竹叶兰</name>

So the question seems to be how can I convert the name section into a HTML escape sequence. I tried -h -E option in exiftool command line but it doesn't work.
How can I make it? modify the kml.fmt file?
Thanks and best regards

Phil Harvey

-E should work.  The problem is that you must remove ";s/&/&amp;" from your reformatting, otherwise you escape the necessary ampersands in the result.

So you should do this:

exiftool -E -p kml.fmt 竹叶兰.jpg > test.kml

with this line in your KML file:

#[BODY]        <name>${filename;s/\.[^.]*$//}</name>

Here I have also modified your expression to remove any extension (not just .jpg).

If that doesn't work, then maybe you need to specify -charset filename=SOMETHING.  It worked for me on Mac, but Windows may be different.

I get this:

> exiftool tmp -p '${filename;s/\.[^.]*$//}'
竹叶兰
    1 directories scanned
    1 image files read

> exiftool tmp -E -p '${filename;s/\.[^.]*$//}'
&#x7af9;&#x53f6;&#x5170;
    1 directories scanned
    1 image files read


- 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 ($).

babelfish

Thanks for fast response, Phil,
I tried
<name>${filename;s/\.[^.]*$//}</name>

and
<name>${filename}</name>

respectly. The result is interesting, I got:
<name>竹&#x4b6;兰</name>

Besides, my windows 10 cmd console codepage is 936.



Phil Harvey

I tried this in Windows and it worked for me when I specified a directory name on the command line instead of a file name.  Maybe this is the easiest solution.  (I don't know how to get these special characters on the command line so I couldn't try it with a file name.)

ExifTool doesn't support -charset with cp936.

It may help to read the Windows Unicode file name section of the documentation, and try using UTF8 instead of cp936.

- 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 ($).