建议PHP code读取文件评级由Adobe CS3桥设置 [英] Suggested php code to read file rating set by Adobe Bridge CS3

查看:274
本文介绍了建议PHP code读取文件评级由Adobe CS3桥设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我​​一直在试图读取正在使用知识共享元数据的工具包PHP没有成功分配在Adobe Bridge CS3的评级。我使用共享的主机,所以我没有一个oppotunity重新编译PHP并使用不同的模块。

Background: I have been attempting to read the rating that is assigned in Adobe Bridge CS3 using the creative commons Metadata toolkit for php without success. I am using shared hosting so I do not have an oppotunity to recompile php with different modules.

PHP是code提供了可用于读取嵌入在.jpg文件的等级?我已阅读,这是一个XMP(XML)文件中的格式部分。

Is php code available that could be used to read the rating that is embedded in the .jpg file? I have read that this is an xmp (xml) formatted section within the file.

推荐答案

我在这里张贴以防别人我的解决方案有一个类似的问题,并读取该线程。以下是我发现:
的Windows Vista 评级添加到嵌入在文件
EXIF​​区段 Adob​​e Bridge中添加了另一款为包含数据XML格式的JPG文件。的XML +数据结构被称为XMP文件。 我还没有处理,使用Adobe Bridge的文件,这就是为什么我无法读取与元数据工具包的XMP数据。

I'm posting my solution here in case someone else has a similiar problem and reads this thread. Here is what I found:
Windows Vista add the rating to the exif section embedded in the file
Adobe Bridge adds another section to the jpg file that contains data formatted in xml. The xml + data structure is referred to as the xmp file. I hadn't yet processed the file with Adobe bridge, that is why I was unable to read the xmp data with the Metadata toolkit.

采用知识共享 - 元数据工具包,我能够读取使用下面的code的收视率。此code是一个Drupal模块的一部分,一些被引用的变量都是Drupal的设置:variable_get()是一个Drupal函数来从perssistent数据存储器读出的变量。

Using the Creative Commons - Metadata toolkit I was able to read the ratings using the following code. This code is part of a Drupal Module, some of the referenced variables are Drupal settings: variable_get() is a Drupal function to read a variable from a perssistent data store.


include_once("PHP_JPEG_Metadata_Toolkit_1.11/JPEG.php");
  include_once("PHP_JPEG_Metadata_Toolkit_1.11/Photoshop_File_Info.php");
  include_once("PHP_JPEG_Metadata_Toolkit_1.11/EXIF.php");
  include_once("PHP_JPEG_Metadata_Toolkit_1.11/XMP.php");

  $photodir = variable_get('rotate_images_sourcefiles_dir',"sites/default/files/imageNodes");

  $rating_threshold = variable_get('rotate_images_rating_threshold',3);
  $allImages=dir($photodir);
  $filenames = scandir($photodir);

  foreach($filenames as $filename){

    $rating = null;
    $info = pathinfo($filename);
    if (strtolower($info['extension'])=="jpg"){
      //  First try to get the rating from the EXIF data, this is where it is stored by Windows Vista
      $exif = get_EXIF_JPEG( $photodir . "/" . $filename );
      $rating = $exif[0][18246]['Data'][0];

      $jpeg_header = get_jpeg_header_data($photodir . "/" . $filename );
      //  If no rating was found in the EXIF data, it may be in the Adobe format xmp section
      if ($rating == null){
        if($jpeg_header != false){
          $xmp = get_XMP_text($jpeg_header);
          $xmpArray = read_XMP_array_from_text($xmp);
          $rating = $xmpArray[0]['children'][0]['children'][0][attributes]['xap:Rating'];
        }   
      }
    }
  }

我也需要通过添加附加条目的EXIF标签阵列修改 EXIF​​_Tags.php 文件中的元数据工具包。我这一情况报告给作者,但我不相信他是维修器材模块下去了。该人士是在SourceForge上,但我不知道如何发布一个补丁。所以,你可能需要作出改变,以EXIF.php自己做出的code的工作。

I did need to modify the EXIF_Tags.php file in the metadata toolkit by adding an additional entry to the EXIF Tags array. I reported this to the author, but I don't believe he is maintaing the module any longer. The source is on sourceforge, but I don't know how to post a patch. So you may need to make the change to EXIF.php yourself to make the code work.


'EXIF' => array (

// Exif IFD

18246 => array ( 'Name' => "Rating",
                'Type' => "Numeric" ), 

这篇关于建议PHP code读取文件评级由Adobe CS3桥设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆