metadata - How can I read XMP data from a JPG with PHP? -


Support for PHP and EXIF ​​and IPTC metadata have been created, but I can not find any way to read XMP?

.

The following shows this process (I am using but every other XML API or even simple and clever string parsing can give you similar results):

  $ content = file_get_contents ($ image); $ Xmp_data_start = strpos ($ content, '& lt; x: xmpmeta'); $ Xmp_data_end = strpos ($ content, '& lt; / x: xmpmeta & gt;'); $ Xmp_length = $ xmp_data_end - $ xmp_data_start; $ Xmp_data = substr ($ content, $ xmp_data_start, $ xmp_length + 12); $ Xmp = Simple XMLload_string ($ xmp_data); Just two comments:  
  • XMP uses XML namespaces heavily, so you have to keep an eye on it, when XMP data will have to be parsed Xml tool
  • Considering the potential size of image files, you probably will not be able to use it because this function loads the entire image in memory to open file-stream processing and key-sequence and lt; X: xmpmeta more data and lt; / X: xmpmeta> To check the amount of data for , the memory footprint.

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -