Extract IPTC using ImageMagick without Entities but UTF-8

泄露秘密 提交于 2019-12-25 04:42:32

问题


I have an image containing ITPC data and use the following command to extract the IPTC as textual data:

convert image.jpg IPTCTEXT:iptc.txt

The problem is that this seems to be using entities for "special characters":

2#120#Caption="Beschreibung für den Import aus IPTC"

Actually it should be "für" here. But instead of getting the correct entity ü for the "ü" character i get two entities (probably both bytes of the UTF-8 encoded character got transformed to entites separated). And these two entites i cannot parse correctly.

Is there any way to get the correct entity or disable the entities completely returning UTF-8 characters?

Edit: I tried parsing the entities using StringEscapeUtils.unescapeXml in Java but i get two characters ("ü") instead of the "ü" as both entities are unescaped separated.

Edit2: Example image here: http://fs1.directupload.net/images/150615/5eiv6wwf.jpg


回答1:


The most reliable metadata package is IMHO exiv2 (http://exiv2.org/; available in all Linux distros, Windows, and not sure about Mac binaries).

See http://paste.fedoraproject.org/232538/34459066/ for results. ImageMagick is for metadata purposes not that great, I am afraid.




回答2:


I am not sure why you are seeing something different from me. I am running ImageMagick 6.9.1-4 on a Mac under OS X.

If I do this:

identify -format "%[IPTC:2:120]" http://fs1.directupload.net/images/150615/5eiv6wwf.jpg

I get this:

Beschreibung für den Import aus EXIF

And if I hex dump that, I get this:

I think it may be related to your Terminal's locale settings - although I don't know why it still happens when you redirect to a file. Have you tried things like:

LC_CTYPE=C identify -format "%[IPTC:2:120]" http://fs1.directupload.net/images/150615/5eiv6wwf.jpg | od -xc


来源:https://stackoverflow.com/questions/30848923/extract-iptc-using-imagemagick-without-entities-but-utf-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!