Reading foreign characters from ImageDescription

Started by GarryJones, June 17, 2022, 10:33:21 AM

Previous topic - Next topic

GarryJones

After following the excellent help sections I was able to set Norwegian and Swedish characters in the ImageDescription by use of a command line ExifTool statements in a BAT file in Windows Command Prompt. The trick was as per the instructions to change the font to Lucinda and issue CHCP 65000 in the first line of BAT file code

When I check these in Adobe Bridge and Windows Explorer they are displayed correctly. But I would like them to show up next to the photo on the web. The Swedish and Norwegian characters in place names and person names show as garble.

This is a photo with a Norwegian character in the Image Description.

This following PHP code is not displaying the character properly. The non Swedish/Norwegian characters display correctly.

$exif = exif_read_data('1.jpg','IFD0',true);
echo $exif["IFD0"]["ImageDescription"];

I know it's possible to do as there is an online website that you can upload the image to and it shows correctly with the Norwegian character.

This is the website that has managed to do it. Unfortunately they do not tell users how...

https://exifdata.com/exif.php

Links
My non-working file:
https://www.garryjones.se/testit/

The actual photo with the Norwegian character in Image Description
https://www.garryjones.se/testit/1.jpg

Basically I just need to know how to display the Image Description correctly with HTML/PHP.

Any help really appreciated...




StarGeek

I found a couple StackExchange posts that might help
php exif_read_data() not in utf-8
exif_read_data: keywords decoded incorrectly

From PHP.net's exif_read_data page
Comment
There's a couple more comments there.  Search UTF on that page.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

GarryJones

Hi

Thanks. I played around with the various options but couldn't work it out.

Many of the help sections and online forums talk of coding for a known character set.

But this online service can read EVERY character.

You upload your photo and the online service displays the exact ImageDescription regardless of character set.

- I really wish they explained how they do it.

https://exifdata.com/exif.php

I mean how difficult can it be to read the Image Description of my photo at garryjones.se/testit/1.jpg ?


StarGeek

Quote from: GarryJones on June 19, 2022, 02:42:16 AM
- I really wish they explained how they do it.

https://exifdata.com/exif.php

They are using exiftool to extract the data.  There are a couple of entries when you upload a file that pop up that are pretty specifically from exiftool, most notably the "Composite" group.  When you add in the fact that they are most likely running on a Linux server, which doesn't have the character coding issues that Windows has, that is how they're extracting the text properly.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype