我在找一条非常具体的信息。我想我可以让这个问题变得相当详细,但我宁愿让它保持简短和切中要害。我需要从Photoshop滤镜插件中访问一段元数据(exif信息)。我从来没有处理过来自Photoshop插件或不包含在Photoshop插件中的exif数据,PS文档的形式留下了很多问题。我最终会做到这一点,但我想知道这里是否有人以前做过这件事,并可以用一个例子来帮助我。我会非常感激的.
我们需要的东西应该记录在SDK中:
documentation/html/group___resource_suite.html
documentation/html/imageresourcessection.html 后一个文档指出,检索exif数据所需的资源ID是1059 (十进制),并且从PS7.0开始支持访问Exif数据,这很好。但是SDK没有(我找到的)关于你得到什么的信息,指针?指向什么的指针?他们只是告诉你去看看exif规范。那么我会得到一个指向原始二进制exif数据的指针吗?如果是这样,我该如何从中提取一个字段。
Exif数据的规范在这里:http://exif.org/specifications.html
作为一个例子,我想从这个exif字段中获取:
Tag Name Field Name Dec Hex Type Count
Image title ImageDescription 270 10E ASCII Any发布于 2012-03-05 21:50:47
编辑:经过更深入的研究,我发现了以下内容(摘自文档):
文档: Photoshop API指南。参数:回调。
回调例程被组织成实现特定功能的相关例程的“套件”集合。
通过指向包含以下内容的记录的指针来描述这些套件:
您对属性套件很感兴趣。
当前版本: 1;Adobe Photoshop: 5.0;例程: 2。
属性由签名和密钥标识,这两个签名和密钥形成一对,用于标识感兴趣的属性。
Adobe 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;发布于 2012-03-05 21:39:02
下面是一个使用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;
}发布于 2015-02-23 19:34:12
我结合了response vulkanino和ThdK。我的方法使用在文件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";
}
}https://stackoverflow.com/questions/9423867
复制相似问题