2012-02-24 74 views
1

我正在寻找非常特定的信息。我可以把这个问题看成是一个相当详细的问题,但我宁愿尽量保持它的简短和重点。 我需要从Photoshop滤镜插件中访问一段元数据(exif信息)。我从来没有从Photoshop插件或没有处理过EXIF数据,而PS SDK文档的形式会留下很多问题。我最终会到那里,但想知道是否有人在这里做过,并可以帮助我一个例子。我会非常感激......如何从Photoshop滤镜插件访问exif数据字段(Photoshop SDK)

我们需要的,应在SDK这里记载:

documentation/html/group___resource_suite.html 
documentation/html/imageresourcessection.html 

后一份文件说,资源ID我需要检索的EXIF数据是1059 (十进制),并且从PS 7.0开始支持访问Exif数据,这很好。但是SDK没有任何信息(我发现)对于你所得到的指针?指向什么?他们只是告诉你看看exif规范。所以我得到一个指向RAW二进制exif数据的指针,如果是的话我该如何从中提取一个字段。

规格的Exif数据中的位置: http://exif.org/specifications.html

作为一个例子,我想获得这个EXIF领域:

Tag Name       Field Name   Dec  Hex  Type Count 
Image title       ImageDescription 270  10E  ASCII Any 

回答

0

编辑:一请参阅以下文档(摘自文档):

文档:Photoshop API指南。 参数:回调。

回调例程被组织成 实现特定功能的相关例程的“套件”集合。

套房由指针描述含有记录:

  1. 为套件2字节的版本号,在该套件例程的数量的
  2. 一个2字节计数,
  3. 一系列回调例程的函数指针。

您对房产套房感兴趣。

当前版本:1; Adobe Photoshop:5.0;例行程序:2.

属性由签名和密钥标识,它们组成一对以 标识感兴趣的属性。

Adob​​e Photoshop的签名总是'8BIM'(0x3842494D)。

EXIF物业由日本电子工业发展协会(JEIDA)和日本电子工业协会(EIAJ)于2000年11月合并控制.EXIF规格可从其网站下载到以下位置。

http://it.jeita.or.jp/jhistory/document/standard/exif_eng/jeida49eng.htm

GetPropertyProc() 

MACPASCAL OSErr (*GetPropertyProc) (OSType signature, OSType key, int32 index, int32 * simpleProperty, Handle * complexProperty); 

这个程序可以让你获取有关当前正在处理的文件信息。

property name: propEXIFData 
id:EXIF 
type:complex (modifiable) 
description:Camera and device data. 

开始我会写一些多汁代码:

GetPropertyProc getProperty = formatParamBlock->propertyProcs->getPropertyProc; 
rc = getProperty(0x3842494D, propEXIFData, 0, &simpProp, &compProp); 
if (rc) 
    return; 

GetPIHandleSizeProc getSize = formatParamBlock->handleProcs->getSizeProc; 
int32 size = getSize(compProp); 
if (!size) 
    return; 

LockPIHandleProc lock = formatParamBlock->handleProcs->lockProc; 
uint8* exif = (uint8 *)lock(compProp, false); 
if (!exif) 
    return; 
+0

谢谢你试图帮忙。这个问题不是关于PiPL,也不是关于'插件的元数据'。问题是关于从任何单个图像中提取元数据。我相信在上面的文档中已经指出了正确的文件。 – 2012-03-05 20:10:50

+0

我已经阅读过imageresourcessection.html文件,但它只指定PSD中EXIT数据存储的位置,您不需要这样做,因为您没有从外部打开PSD。相反,从插件中,您应该调用API(SDK)函数来获取EXIF信息,即您应该查询属性。 – vulkanino 2012-03-06 08:17:01

+0

我必须稍后再阅读。自那时以来,我给了你赏金。毕竟,你的答案是最有用的。 – 2012-03-06 17:17:48

0

这里的是使用Exiv2库中的代码示例: http://www.exiv2.org/doc/exifprint_8cpp-example.html

// ***************************************************************** -*- C++ -*- 
// exifprint.cpp, $Rev: 2286 $ 
// Sample program to print the Exif metadata of an image 

#include <exiv2/exiv2.hpp> 

#include <iostream> 
#include <iomanip> 
#include <cassert> 

int main(int argc, char* const argv[]) 

try { 

if (argc != 2) { 
    std::cout << "Usage: " << argv[0] << " file\n"; 
    return 1; 
} 

Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]); 
assert(image.get() != 0); 
image->readMetadata(); 

Exiv2::ExifData &exifData = image->exifData(); 
if (exifData.empty()) { 
    std::string error(argv[1]); 
    error += ": No Exif data found in the file"; 
    throw Exiv2::Error(1, error); 
} 
Exiv2::ExifData::const_iterator end = exifData.end(); 
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) { 
    const char* tn = i->typeName(); 
    std::cout << std::setw(44) << std::setfill(' ') << std::left 
       << i->key() << " " 
       << "0x" << std::setw(4) << std::setfill('0') << std::right 
       << std::hex << i->tag() << " " 
       << std::setw(9) << std::setfill(' ') << std::left 
       << (tn ? tn : "Unknown") << " " 
       << std::dec << std::setw(3) 
       << std::setfill(' ') << std::right 
       << i->count() << " " 
       << std::dec << i->value() 
       << "\n"; 
} 

return 0; 
} 
//catch (std::exception& e) { 

//catch (Exiv2::AnyError& e) { 

catch (Exiv2::Error& e) { 
    std::cout << "Caught Exiv2 exception '" << e.what() << "'\n"; 
    return -1; 
} 
+1

这是photoshop SDK? – vulkanino 2012-03-05 13:43:18

+0

因为我说我没有处理PS插件之外的Exif信息......感谢您发布此信息。我之前找到过相同的库,甚至可以用于商业用途。然而,一个简单的从另一个网站的主题源代码复制/粘贴并不是我所希望的。 – 2012-03-05 20:14:42

0

我结合响应vulkaninoThdK。我的方法使用文件PropertyUtils.h中声明的函数PIGetEXIFData返回一个二进制exif。下一步,这个exif解码Exiv2

#include <PropertyUtils.h> 
#include <PIProperties.h> 

#include <exif.hpp> 

void printExif() { 
    Handle handle; 
    checkSPErr(PIGetEXIFData(handle)); 
    std::string ss; 
    checkSPErr(HandleToString(handle, ss)); 

    Exiv2::ExifData exifData; 
    Exiv2::ExifParser::decode(exifData, reinterpret_cast<const Exiv2::byte*>(ss.data()), ss.size()); 
    Exiv2::ExifData::const_iterator end = exifData.end(); 
    for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) { 
     const char* tn = i->typeName(); 
     std::cout << std::setw(44) << std::setfill(' ') << std::left 
      << i->key() << " " 
      << "0x" << std::setw(4) << std::setfill('0') << std::right 
      << std::hex << i->tag() << " " 
      << std::setw(9) << std::setfill(' ') << std::left 
      << (tn ? tn : "Unknown") << " " 
      << std::dec << std::setw(3) 
      << std::setfill(' ') << std::right 
      << i->count() << " " 
      << std::dec << i->value() 
      << "\n"; 
    } 
} 
+0

解释你的答案很有帮助,而不仅仅是提供一些代码。 – 2015-02-23 11:57:03