2012-02-24 77 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