So I'm using glob()
function in foreach
to render images from folder on my site and I want to have titles in there, so I put title in meta data of that image, but when I execute those meta data via exif_read_data() it will execute not in utf-8, it shows POL`T?XE this instead of this POLŠTÁŘE.
This is my code with some tries of solving this problem
header("Content-Type: text/html; charset=utf-8");
ini_set('exif.encode_unicode', 'UTF-8');
iconv_set_encoding('input_encoding', 'UTF-8');
iconv_set_encoding('output_encoding', 'UTF-8');
iconv_set_encoding('internal_encoding', 'UTF-8');
$dirs = array_filter(glob('img/*'), 'is_dir');
foreach ($dirs as $dir) {
$files = glob($dir.'/*.{jpg,png,JPG,PNG,jpeg,JPEG}', GLOB_BRACE);
foreach($files as $file) {
$meta_data = exif_read_data($file, 0, true);
echo '
<img src="'.$file.'" title="'.$meta_data['IFD0']['Title'].'" />
';
}
}
Nothing of it worked, even when I used exiftools.
Not even with utf8_encode()
and not even mb_convert_encoding($meta_data['IFD0']['Title'], 'UTF-8')
.
When I used this mb_detect_encoding()
function it executed UTF-8.
And I tried to set encoding to utf-8 with exiftool and it didn't work either. Can you help me?