I'm getting the 'Comments' information from a uploaded image with the exif_read_data function. I want to insert this information into the corresponding image 'alt' tag. The inserted value looks like this: T�r�a�v�e�l���
I tried several encoding variants but i can't get a proper string.
PHP:
$exif = exif_read_data($dir.$image , 0 ,true);
$rel = $exif["IFD0"]["Comments"];
HTML:
<img alt='$rel' src='test.jpg' />
OUTPUT: something like this...
<img alt='T�r�a�v�e�l��� ' src='test.jpg' />
The actual encoding for the html page is UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
I don't know if will solve your problem (if yes, let me know here). But there's a comment at php.net with a php.ini config to set the exif encoding:
<?php
ini_set('exif.encode_unicode', 'UTF-8');
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With