冷冻中的IPTC数据9

时间:2012-02-03 15:52:54

标签: coldfusion iptc

我正在使用coldfusion的imageGetIPTCMetadata()函数来获取iptc关键字。

我使用Photomechanics以这种分层方式插入一些关键字

Personnel   |   Appointments   |   Assistant Chief of General Staff (ACGS), Personnel  |  Ranks  |  Royal Marine  |  Colour Sergeant (CSgt), Personnel | Ranks | Royal Navy | Chief Petty Officer (CPO), Personnel|Ranks|Army|Field Marshall (Fd Marshall) (FM)

但是在我在CFC中调用该方法后,我得到了这个 -

如何使用分隔符或其他内容获取关键字,以便我可以在代码中重复使用它们。

enter image description here

3 个答案:

答案 0 :(得分:1)

如果我正确理解了您的问题,您可以使用List functions之一ListGetAt来获取带分隔符的关键字。或者,如果您更喜欢使用数组,则可以使用ListToArray函数keywordsArray = ListToArray(data.Keywords,"|")

<cfscript>  
    data = ImageGetIPTCMetadata(myImage);

    for( i=1; i LTE ListLen(data.Keywords,"|"); i++ )
    {
        WriteOutput( Trim( ListGetAt(data.Keywords, i, "|") ) & "<br />" );
    }
</cfscript>

答案 1 :(得分:0)

我找到了解决方案here

<cfparam name="URL.source" default="xmp-asset.jpg">
<cffile action="readbinary" file="#ExpandPath(URL.source)#" variable="data">
<!-- encode the binary data to hex -->
<cfset hex_data = BinaryEncode(data,"hex") />
<!-- string indicating beginning of packet '<x:xmpmeta' -->
<cfset xmp_string_begin = "3C783A786D706D657461" />
<!-- string indicating end of packet '</x:xmpmeta>' -->
<cfset xmp_string_end = "3C2F783A786D706D6574613E" />
<!-- find the starting index in the hex string -->
<cfset idx_start = FindNoCase(xmp_string_begin,hex_data) />
<!-- find the ending index in the hex string -->
<cfset idx_end = FindNoCase(xmp_string_end,hex_data,idx_start) + Len(xmp_string_end) />
<!-- using the start and end indices, extract the xmp packet -->
<cfset xmp_hex = Mid(hex_data,idx_start,Evaluate(idx_end-idx_start)) />
<!-- convert the hex to readable characters -->
<cfset xmp_string = ToString(BinaryDecode(xmp_hex,"hex")) />
<!-- parse the xml string to and xml structure -->
<cfset xmp_xml = XmlParse(xmp_string) />
<cfcontent type="text/xml">
<cfoutput>#xmp_string#</cfoutput>

现在我可以获得整个XMP xml并完成我想要处理的所有数据。

答案 2 :(得分:0)

我使用CFX_OpenImage在CF8到CF11的.jpg文件中读写IPTC_数据。我也用它来调整图像大小和旋转。

更多CFX_OPENIMAGE INFO转到http://www.kolumbus.fi/jukka.manner/cfx_openimage/

It GraphicsMagick 1.3.17。
GraphicsMagick(www.graphicsmagick.org)维护一个稳定的发布分支,维护一个详细的更改日志,并维护一个具有完整版本历史记录的稳定源存储库,以便控制更改,并准确描述版本之间的更改。 GraphicsMagick为发布分支提供持续支持 更多安装信息:

注意:如果要安装64位版本的标记,请从Microsoft(http://www.microsoft.com/download/en/details.aspx?id=14632)下载并安装Microsoft Visual C ++ 2010 Redistributable Package(x64)。 x64版本已在Visual Studio 2010中编译和编写 两个版本共有的CFX_OPENIMAGE安装步骤:
创建环境变量由于GraphicsMagick需要读取配置文件(* .mgk文件),我们需要告诉标记这些文件的位置。为此,必须设置系统或冷融合运行时用户特定的环境变量。该变量的名称为CFX_OPENIMAGE_FULLPATH CFX_OPENIMAGE_FULLPATH环境变量应包含完整路径名,该路径名指向保存所有mgk文件和cfx_openimage.ini文件的目录。默认值为“c:\ cfx_openimage \”。请注意,也需要最后一个“\”字符 你可以在任何你喜欢的地方安装实际的dll,无论如何都要通过CF管理页面进行注册。为了保持所有文件的安全设置相等,建议将cfx_openimage.dll保存在* .mgk和cfx_openimage.ini目录所在的目录中。

相关问题