如何从 Photoshop 滤镜插件 (Photoshop SDK) 访问 exif 数据字段

发布于 2025-01-08 15:40:49 字数 764 浏览 0 评论 0原文

我正在寻找一条非常具体的信息。我想我可以提出一个相当详细的问题,但我宁愿尝试使其简短明了。 我需要从 Photoshop 滤镜插件中访问一段元数据(exif 信息)。我从未处理过 Photoshop 插件内部或外部的 exif 数据,而且 PS SDK 文档的形式留下了很多问题。我最终会到达那里,但想知道这里是否有人以前做过这件事并且可以帮助我举个例子。我将非常感激...

我们需要的内容应该记录在 SDK 中:

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

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

Exif 数据的规范如下: 作为一个

例子,我想了解这个 exif场地:

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

I'm looking for a very specific piece of information. I could make this a rather detailed question I guess but I'd rather try keeping it short and to the point.
I need to acces a piece of meta data (exif information) from within a Photoshop filter plug-in. I have never dealt with exif data from within a Photoshop plug-in or without and the PS SDK documentation is of a form that leaves a lot of questions. I would eventually get there but was wondering if anyone here has done this before and could help me out with an example. I'd be very grateful for that...

What we need should be documented here in the SDK:

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

The latter document says that the resource ID I need to retrieve the exif data is 1059 (decimal) and that accessing Exif data is supported since PS 7.0 which is good. But the SDK has no information (that I found) as to what you get, pointer? pointer to what? They just tell you to look at the exif spec. So do I get a pointer to the RAW binary exif data and if so how to I extract a field from that.

The specifications for the Exif data are here:
http://exif.org/specifications.html

As an example I'd like to get at this exif field:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一杯敬自由 2025-01-15 15:40:49

编辑:经过更深入的研究,我发现了以下内容(文档摘录):

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

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

这些套件由指向记录的指针来描述,该记录包含:

  1. 套件的 2 字节版本号、
  2. 套件中例程数量的 2 字节计数、
  3. 回调例程的一系列函数指针。

您对属性套件感兴趣。

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

属性由签名和密钥标识,它们形成一对
识别感兴趣的财产。

Adobe Photoshop 的签名始终为“8BIM”(0x3842494D)。

EXIF 属性由 2000 年 11 月合并的日本电子工业振兴协会 (JEIDA) 和日本电子工业协会 (EIAJ) 控制。 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;

EDIT: After a deeper research I've found the following (an excerpt from the documentation):

Document: Photoshop API Guide.
Argument: Callbacks.

The callback routines are organized into “suites” collections of
related routines which implement a particular functionality.

The suites are described by a pointer to a record containing:

  1. a 2 byte version number for the suite,
  2. a 2 byte count of the number of routines in the suite,
  3. a series of function pointers for the callback routines.

You are interested in the Property suite.

Current version: 1; Adobe Photoshop: 5.0; Routines: 2.

Properties are identified by a signature and key, which form a pair to
identify the property of interest.

Adobe Photoshop’s signature is always '8BIM' (0x3842494D).

The EXIF property is controlled by The Japan Electronic Industry Development Association (JEIDA) and Electronic Industries Association of Japan (EIAJ) which merged in Novemeber of 2000. The EXIF specification can be downloaded from their web site at the following location.

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);

This routine allows you to get information about the document currently being processed.

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

To recap I'll write some juicy code:

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;
野生奥特曼 2025-01-15 15:40:49

以下是使用 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;
}

Here's is a code sample using the Exiv2 Library: 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;
}
内心激荡 2025-01-15 15:40:49

我结合了响应 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";
    }
}

I combined response vulkanino and ThdK. My method uses the function PIGetEXIFData declared in file PropertyUtils.h that returns a binary exif. Next, this exif decoded Exiv2 library

#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";
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文