显示带有PHP的JPG照片中成像

发布于 2025-02-08 06:14:38 字数 763 浏览 2 评论 0原文

在图像描述中,我有一张带有挪威角色的照片。此PHP代码未正确显示该字符。

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

该字符是正确编写的,因为我可以在Windows和Adobe Bridge中看到它。同样,当我将同一文件上传到此在线查看器时,图像描述使用挪威字符正确显示。

https://exifdata.com/exif.php.php

我知道这是可能的,但是他们不' t列出他们的来源。

任何帮助都得到了很大的收获。

下方的链接

在我的非工作文件 : https://www.garryjones.se/testit/

图像描述中带有挪威角色的照片 https://www.garryjones.se/testit/1.jpg

I have a photo with a Norwegian character in the Image Description. This PHP code is not displaying the character properly.

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

The character is written correctly as it I can see it in Windows and Adobe Bridge. Also when I upload the same file to this online viewer the Image Description displays correctly with the Norwegian character.

https://exifdata.com/exif.php

So I know it is possible, but they don't list their source.

Any help greatly received.

Links Below

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2025-02-15 06:14:38

如果启用了MBSTRING,EXIF将尝试处理Unicode和
选择Exif.decode_unicode_motorola和
exif.decode_unicode_intel。 EXIF扩展将不会尝试
单独找出编码,这取决于用户
通过设置正确指定用于解码的编码
在调用exif_read_data()之前,这两个INI指令之一。

您只需要找出如何执行ini设置,但是幸运的是,有人在15年前添加了该信息,请参阅: https://www.php.net/manual/manual/en/en/en/function.exif-read-data.php#73645

在阅读“ WinXP”组的EXIF信息时,您可能需要
更改使用的编码从默认的“ ISO-8859-15”到“ UTF-8”。这
可以在php.ini或您的代码中完成:

  ini_set('exif.encode_unicode','utf-8');

    $ exif = exif_read_data('test.jpg',0,true);
    echo $ exif ['winxp'] ['title']; ?> ````````
 

In the docs, there is a NOTE:

If mbstring is enabled, exif will attempt to process the unicode and
pick a charset as specified by exif.decode_unicode_motorola and
exif.decode_unicode_intel. The exif extension will not attempt to
figure out the encoding on its own, and it is up to the user to
properly specify the encoding for which to use for decoding by setting
one of these two ini directives prior to calling exif_read_data().

You only have to find out how to do the ini setting, but luckily someone added that info 15 years ago, see: https://www.php.net/manual/en/function.exif-read-data.php#73645

When reading EXIF information from the 'WINXP' group, you may need to
change used encoding from the default "ISO-8859-15" to "UTF-8". This
can be done in php.ini or in your code:

    ini_set('exif.encode_unicode', 'UTF-8');

    $exif = exif_read_data('TEST.JPG', 0, true);
    echo $exif['WINXP']['Title']; ?> ```
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文