如何从Photoshop过滤器插件(Photoshop SDK)访问exif数据字段
How to access a field of exif data from a Photoshop filter plug-in (Photoshop SDK)
我正在寻找一条非常具体的信息。我想我可以把这个问题说得相当详细,但我宁愿尽量简明扼要。我需要从Photoshop过滤器插件中访问一段元数据(exif信息)。我从来没有处理过Photoshop插件内或外的exif数据,PS SDK文档的形式留下了很多问题。我最终会到达那里,但我想知道这里是否有人以前做过这件事,可以用一个例子来帮助我。我会非常感激。。。
我们需要的东西应该记录在SDK中:
documentation/html/group___resource_suite.html
documentation/html/imageresourcessection.html
后一份文件说,我需要检索exif数据的资源ID是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
EDIT:经过更深入的研究,我发现了以下内容(摘录自文档):
文件:Photoshop API指南。参数:回调。
回调例程被组织为实现特定功能的相关例程。
套件由指向记录的指针描述,该记录包含:
- 套件的2字节版本号
- 套件中的例程数量的2字节计数
- 回调例程的一系列函数指针
您对属性套件感兴趣。
当前版本:1;Adobe Photoshop:5.0;常规:2。
属性由签名和密钥标识,它们形成一对确定感兴趣的财产。
Adobe Photoshop的签名始终为"8BIM"(0x384494D)
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;
以下是使用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] << " filen";
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;
}
I联合反应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";
}
}
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- 用于访问容器<T>数据成员的正确 API
- 访问者访问变体并返回不同类型时出错
- 尝试通过多个向量访问变量时,向量下标超出范围
- 无法访问嵌套类.类的使用无效
- 写入位置0x0000000C时发生访问冲突
- 我们可以访问一个不存在的联盟的成员吗
- C++从另一个类访问公共静态向量的正确方法是什么
- 我的简单if-else语句是如何无法访问的代码
- 从C++dll访问C#中的一行主要参数
- 概念TS检查忽略私有访问修饰符
- 访问被拒绝后,c++中的故障保护代码
- 在c++中访问int到类对象的映射时出错
- 我想访问std::unique_ptr中的一个特定元素
- 为什么示例代码访问IUnknown中已删除的内存
- C++:无法访问声明的受保护成员
- 通过指向指针数组的指针访问子类的属性
- 如何从Photoshop过滤器插件(Photoshop SDK)访问exif数据字段