Module: Exempi

Extended by:
FFI::Library
Defined in:
lib/exempi/errors.rb,
lib/exempi/consts.rb,
lib/exempi/exempi.rb,
lib/exempi/version.rb,
lib/exempi/exceptions.rb,
lib/exempi/namespaces.rb

Overview

Copyright 2002 Adobe Systems Incorporated All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms of the Adobe license agreement accompanying it.

Copyright © 1999 - 2010, Adobe Systems IncorporatedAll rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of Adobe Systems Incorporated, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS“AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Defined Under Namespace

Modules: Namespaces Classes: ExempiError, InvalidOptionError, XmpDateTime

Constant Summary collapse

XMP_OPEN_FILE_OPTIONS =

Option bits for xmp_files_open()

enum [
  :XMP_OPEN_NOOPTION,           0x00000000, # No open option
  :XMP_OPEN_READ,               0x00000001, # Open for read-only access.
  :XMP_OPEN_FORUPDATE,          0x00000002, # Open for reading and writing.
  :XMP_OPEN_ONLYXMP,            0x00000004, # Only the XMP is wanted, allows space/time optimizations.
  :XMP_OPEN_CACHETNAIL,         0x00000008, # Cache thumbnail if possible, GetThumbnail will be called.
  :XMP_OPEN_STRICTLY,           0x00000010, # Be strict about locating XMP and reconciling with other forms.
  :XMP_OPEN_USESMARTHANDLER,    0x00000020, # Require the use of a smart handler.
  :XMP_OPEN_USEPACKETSCANNING,  0x00000040, # Force packet scanning, don't use a smart handler.
  :XMP_OPEN_LIMITSCANNING,      0x00000080, # Only packet scan files "known" to need scanning.
  :XMP_OPEN_REPAIR_FILE,        0x00000100, # Attempt to repair a file opened for update, default is to not open (throw an exception).
  :XMP_OPEN_INBACKGROUND,       0x10000000  # Set if calling from background thread.
]
XMP_CLOSE_FILE_OPTIONS =

Option bits for xmp_files_close()

enum [
  :XMP_CLOSE_NOOPTION,   0x0000,
  :XMP_CLOSE_SAFEUPDATE, 0x0001
]
XMP_FILE_TYPE =

File formats

enum [
  :XMP_FT_PDF,     0x50444620,  # 'PDF '
  :XMP_FT_PS,      0x50532020,  # 'PS  ', general PostScript following DSC conventions.
  :XMP_FT_EPS,     0x45505320,  # 'EPS ', encapsulated PostScript.

  :XMP_FT_JPEG,    0x4A504547,  # 'JPEG'
  :XMP_FT_JPEG2K,  0x4A505820,  # 'JPX ', ISO 15444-1
  :XMP_FT_TIFF,    0x54494646,  # 'TIFF'
  :XMP_FT_GIF,     0x47494620,  # 'GIF '
  :XMP_FT_PNG,     0x504E4720,  # 'PNG '
  
  :XMP_FT_SWF,     0x53574620,  # 'SWF '
  :XMP_FT_FLA,     0x464C4120,  # 'FLA '
  :XMP_FT_FLV,     0x464C5620,  # 'FLV '

  :XMP_FT_MOV,     0x4D4F5620,  # 'MOV ', Quicktime
  :XMP_FT_AVI,     0x41564920,  # 'AVI '
  :XMP_FT_CIN,     0x43494E20,  # 'CIN ', Cineon
  :XMP_FT_WAV,     0x57415620,  # 'WAV '
  :XMP_FT_MP3,     0x4D503320,  # 'MP3 '
  :XMP_FT_SES,     0x53455320,  # 'SES ', Audition session
  :XMP_FT_CEL,     0x43454C20,  # 'CEL ', Audition loop
  :XMP_FT_MPEG,    0x4D504547,  # 'MPEG'
  :XMP_FT_MPEG2,   0x4D503220,  # 'MP2 '
  :XMP_FT_MPEG4,   0x4D503420,  # 'MP4 ', ISO 14494-12 and -14
  :XMP_FT_WMAV,    0x574D4156,  # 'WMAV', Windows Media Audio and Video
  :XMP_FT_AIFF,    0x41494646,  # 'AIFF'

  :XMP_FT_HTML,    0x48544D4C,  # 'HTML'
  :XMP_FT_XML,     0x584D4C20,  # 'XML '
  :XMP_FT_TEXT,    0x74657874,  # 'text'

  # Adobe application file formats.
  :XMP_FT_PHOTOSHOP,        0x50534420,  # 'PSD '
  :XMP_FT_ILLUSTRATOR,      0x41492020,  # 'AI  '
  :XMP_FT_INDESIGN,         0x494E4444,  # 'INDD'
  :XMP_FT_AEPROJECT,        0x41455020,  # 'AEP '
  :XMP_FT_AEPROJTEMPLATE,   0x41455420,  # 'AET ', After Effects Project Template
  :XMP_FT_AEFILTERPRESET,   0x46465820,  # 'FFX '
  :XMP_FT_ENCOREPROJECT,    0x4E434F52,  # 'NCOR'
  :XMP_FT_PREMIEREPROJECT,  0x5052504A,  # 'PRPJ'
  :XMP_FT_PREMIERETITLE,    0x5052544C,  # 'PRTL'

  # Catch all.
  :XMP_FT_UNKNOWN, 0x20202020
]
XMP_FILE_FORMAT_OPTIONS =
enum [
  :XMP_FMT_CAN_INJECT_XMP,        0x00000001,
  :XMP_FMT_CAN_EXPAND,            0x00000002,
  :XMP_FMT_CAN_REWRITE,           0x00000004,
  :XMP_FMT_PREFERS_IN_PLACE,      0x00000008,
  :XMP_FMT_CAN_RECONCILE,         0x00000010,
  :XMP_FMT_ALLOWS_ONLY_XMP,       0x00000020,
  :XMP_FMT_RETURNS_RAW_PACKET,    0x00000040,
  :XMP_FMT_HANDLER_OWNS_FILE,     0x00000100,
  :XMP_FMT_ALLOW_SAFE_UPDATE,     0x00000200,
  :XMP_FMT_NEEDS_READONLY_PACKET, 0x00000400,
  :XMP_FMT_USE_SIDECAR_XMP,       0x00000800,
  :XMP_FMT_FOLDER_BASED_FORMAT,   0x00001000,
  :_XMP_FMT_LAST
]
XMP_ITER_OPTIONS =
enum [
  :XMP_ITER_CLASSMASK,      0x00FF,  # The low 8 bits are an enum of what data structure to iterate.
  :XMP_ITER_PROPERTIES,     0x0000,  # Iterate the property tree of a TXMPMeta object.
  :XMP_ITER_ALIASES,        0x0001,  # Iterate the global alias table.
  :XMP_ITER_NAMESPACES,     0x0002,  # Iterate the global namespace table.
  :XMP_ITER_JUSTCHILDREN,   0x0100,  # Just do the immediate children of the root, default is subtree.
  :XMP_ITER_JUSTLEAFNODES,  0x0200,  # Just do the leaf nodes, default is all nodes in the subtree.
  :XMP_ITER_JUSTLEAFNAME,   0x0400,  # Return just the leaf part of the path, default is the full path.
  :XMP_ITER_INCLUDEALIASES, 0x0800,  # Include aliases, default is just actual properties.
  :XMP_ITER_OMITQUALIFIERS, 0x1000   # Omit all qualifiers.
]
XMP_ITER_SKIP_OPTIONS =
enum [
  :XMP_ITER_SKIPSUBTREE,   0x0001, # Skip the subtree below the current node.
  :XMP_ITER_SKIPSIBLINGS,  0x0002 # Skip the subtree below and remaining siblings of the current node.
]
XMP_PROPS_BITS =
enum [
  # Options relating to the XML string form of the property value.
  :XMP_PROP_VALUE_IS_URI,     0x00000002, # The value is a URI, use rdf:resource attribute.
                                         # DISCOURAGED

  # Options relating to qualifiers attached to a property.
  :XMP_PROP_HAS_QUALIFIERS,   0x00000010, # The property has qualifiers, includes rdf:type and xml:lang.
  :XMP_PROP_IS_QUALIFIER,     0x00000020, # This is a qualifier, includes rdf:type and xml:lang.
  :XMP_PROP_HAS_LANG,         0x00000040, # Implies XMP_PropHasQualifiers, property has xml:lang.
  :XMP_PROP_HAS_TYPE,         0x00000080, # Implies XMP_PropHasQualifiers, property has rdf:type.
  
  # Options relating to the data structure form.
  :XMP_PROP_VALUE_IS_STRUCT,  0x00000100, # The value is a structure with nested fields.
  :XMP_PROP_VALUE_IS_ARRAY,   0x00000200, # The value is an array (RDF alt/bag/seq).
  :XMP_PROP_ARRAY_IS_UNORDERED, 0x00000200,  # The item order does not matter. (e.g. same as XMP_PROP_VALUE_IS_ARRAY)
  :XMP_PROP_ARRAY_IS_ORDERED, 0x00000400, # Implies XMP_PropValueIsArray, item order matters.
  :XMP_PROP_ARRAY_IS_ALT,     0x00000800, # Implies XMP_PropArrayIsOrdered, items are alternates.
  
  # Additional struct and array options.
  :XMP_PROP_ARRAY_IS_ALTTEXT,    0x00001000, # Implies kXMP_PropArrayIsAlternate, items are localized text.
  :XMP_PROP_ARRAY_INSERT_BEFORE, 0x00004000, # Used by array functions.
  :XMP_PROP_ARRAY_INSERT_AFTER,  0x00008000, # Used by array functions.
  
  # Other miscellaneous options.
  :XMP_PROP_IS_ALIAS,         0x00010000, # This property is an alias name for another property.
  :XMP_PROP_HAS_ALIASES,      0x00020000, # This property is the base value for a set of aliases.
  :XMP_PROP_IS_INTERNAL,      0x00040000, # This property is an "internal" property, owned by applications.
  :XMP_PROP_IS_STABLE,        0x00100000, # This property is not derived from the document content.
  :XMP_PROP_IS_DERIVED,       0x00200000, # This property is derived from the document content.

  # Note that these are commented out in Exempi
  # kXMPUtil_AllowCommas,   0x10000000UL,  ! Used by TXMPUtils::CatenateArrayItems and ::SeparateArrayItems.
  # kXMP_DeleteExisting,    0x20000000UL,  ! Used by TXMPMeta::SetXyz functions to delete any pre-existing property.
  # kXMP_SchemaNode,        0x80000000UL,  ! Returned by iterators - #define to avoid warnings

  # Original values of these bitmasks noted; we can't access them by name
  # XMP_PROP_ARRAY_FORM_MASK  = XMP_PROP_VALUE_IS_ARRAY | XMP_PROP_ARRAY_IS_ORDERED | XMP_PROP_ARRAY_IS_ALT | XMP_PROP_ARRAY_IS_ALTTEXT,
  :XMP_PROP_ARRAY_FORM_MASK,  0x00000200 | 0x00000400 | 0x00000800 | 0x00001000,

  # XMP_PROP_COMPOSITE_MASK   = XMP_PROP_VALUE_IS_STRUCT | XMP_PROP_ARRAY_FORM_MASK,  /* Is it simple or composite (array or struct)? */
  :XMP_PROP_COMPOSITE_MASK,   0x00000100 | 0x00001E00,
  :XMP_IMPL_RESERVED_MASK,    0x70000000   # Reserved for transient use by the implementation.
]
XMP_LITTLEENDIAN_BIT =

These values are used in the enum below

0x0001
XMP_UTF16_BIT =

! Don’t use directly, see the combined values below!

0x0002
XMP_UTF32_BIT =
0x0004
XMP_SERIAL_OPTIONS =

Options for xmp_serialize Unnamed in exempi, named :XmpSerialOptions here

enum [
  :XMP_SERIAL_OMITPACKETWRAPPER,   0x0010,  # Omit the XML packet wrapper. */
  :XMP_SERIAL_READONLYPACKET,      0x0020,  # Defat is a writeable packet. */
  :XMP_SERIAL_USECOMPACTFORMAT,    0x0040,  # Use a compact form of RDF. */
  
  :XMP_SERIAL_INCLUDETHUMBNAILPAD, 0x0100,  # Include a padding allowance for a thumbnail image. */
  :XMP_SERIAL_EXACTPACKETLENGTH,   0x0200,  # The padding parameter is the overall packet length. */
  :XMP_SERIAL_WRITEALIASCOMMENTS,  0x0400,  # Show aliases as XML comments. */
  :XMP_SERIAL_OMITALLFORMATTING,   0x0800,  # Omit all formatting whitespace. */
  
  :XMP_SERIAL_ENCODINGMASK,        0x0007,
  :XMP_SERIAL_ENCODEUTF8,          0,
  :XMP_SERIAL_ENCODEUTF16BIG,      XMP_UTF16_BIT,
  :XMP_SERIAL_ENCODEUTF16LITTLE,   XMP_UTF16_BIT | XMP_LITTLEENDIAN_BIT,
  :XMP_SERIAL_ENCODEUTF32BIG,      XMP_UTF32_BIT,
  :XMP_SERIAL_ENCODEUTF32LITTLE,   XMP_UTF32_BIT | XMP_LITTLEENDIAN_BIT
]
TzSignValues =

Values used for tzSign field. Another unnamed enum, used in XmpDateTime below

enum [
  :XMP_TZ_WEST, -1, # West of UTC
  :XMP_TZ_UTC,  0,  # UTC
  :XMP_TZ_EAST, +1  # East of UTC
]
ErrorCodes =

This maps the numeric exceptions to their names. The numeric values are output by xmp_get_error()

{
    # More or less generic error codes.
     0     =>  :XMPErr_Unknown,
    -1     =>  :XMPErr_TBD,
    -2     =>  :XMPErr_Unavailable,
    -3     =>  :XMPErr_BadObject,
    -4     =>  :XMPErr_BadParam,
    -5     =>  :XMPErr_BadValue,
    -6     =>  :XMPErr_AssertFailure,
    -7     =>  :XMPErr_EnforceFailure,
    -8     =>  :XMPErr_Unimplemented,
    -9     =>  :XMPErr_InternalFailure,
    -10    =>  :XMPErr_Deprecated,
    -11    =>  :XMPErr_ExternalFailure,
    -12    =>  :XMPErr_UserAbort,
    -13    =>  :XMPErr_StdException,
    -14    =>  :XMPErr_UnknownException,
    -15    =>  :XMPErr_NoMemory,

    # More specific parameter error codes.
    -101   =>  :XMPErr_BadSchema,
    -102   =>  :XMPErr_BadXPath,
    -103   =>  :XMPErr_BadOptions,
    -104   =>  :XMPErr_BadIndex,
    -105   =>  :XMPErr_BadIterPosition,
    -106   =>  :XMPErr_BadParse,
    -107   =>  :XMPErr_BadSerialize,
    -108   =>  :XMPErr_BadFileFormat,
    -109   =>  :XMPErr_NoFileHandler,
    -110   =>  :XMPErr_TooLargeForJPEG,

    # File format and internal structure error codes.
    -201   =>  :XMPErr_BadXML,
    -202   =>  :XMPErr_BadRDF,
    -203   =>  :XMPErr_BadXMP,
    -204   =>  :XMPErr_EmptyIterator,
    -205   =>  :XMPErr_BadUnicode,
    -206   =>  :XMPErr_BadTIFF,
    -207   =>  :XMPErr_BadJPEG,
    -208   =>  :XMPErr_BadPSD,
    -209   =>  :XMPErr_BadPSIR,
    -210   =>  :XMPErr_BadIPTC,
    -211   =>  :XMPErr_BadMPEG
}
VERSION =
"0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.verbose=(value) ⇒ Object (writeonly)

Sets the attribute verbose

Parameters:

  • value

    the value to set the attribute verbose to.



49
50
51
# File 'lib/exempi/exempi.rb', line 49

def verbose=(value)
  @verbose = value
end

Class Method Details

.attach_function(name, func, args, returns = nil, options = {}) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/exempi/exempi.rb', line 51

def attach_function name, func, args, returns=nil, options={}
  super
  old_method = method(name)
  define_singleton_method(name) do |*args|
    shutup! { old_method.call(*args) }
  end
end

.exception_for(code) ⇒ Object

Returns a symbol representing the XMP error for an int code. Used with the output of Exempi.xmp_get_error This is just a bit of sugar over Exempi::ErrorCodes

Parameters:

  • code (Integer)

    integer error code; should be obtained from Exempi.xmp_get_error



91
92
93
94
95
96
# File 'lib/exempi/errors.rb', line 91

def self.exception_for code
  if !ErrorCodes[code]
    raise ArgumentError, "#{error_code} is not an Exempi error code"
  end
  ErrorCodes[code]
end

.parse_bitmask(int, enum, short_name = false) ⇒ Hash

Converts a bitfield into a hash of named options via bitwise AND.

Parameters:

  • int (Integer)

    the bitfield integer

  • enum (FFI::Enum)

    the enum with which to compare

  • short_name (Boolean) (defaults to: false)

    true to return shortened option names

Returns:

  • (Hash)

    a hash which includes symbol representations of the included options



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/exempi/consts.rb', line 323

def self.parse_bitmask int, enum, short_name=false
  enum_hash = enum.to_hash
  opt_hash = {}
  enum_hash.each do |k,v|
    if short_name
      option = k.to_s.split("_")[2..-1].join("_").downcase.to_sym
    else
      option = k
    end

    opt_hash[option] = ((int & v) == v)
  end

  opt_hash
end

.verbose?Boolean

Returns:

  • (Boolean)


48
# File 'lib/exempi/exempi.rb', line 48

def verbose?; @verbose; end

Instance Method Details

#xmp_copyFFI::Pointer

Create a new XMP packet from the one passed.

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the instance to copy. Can be NULL.

Returns:

  • (FFI::Pointer)

    the packet pointer. NULL is failer (or NULL is passed).



163
# File 'lib/exempi/exempi.rb', line 163

attach_function :xmp_copy, [ :pointer ], :pointer

#xmp_files_check_file_formatInteger

Check the file format of a file. Use the same logic as in xmp_files_open()

Parameters:

  • filePath (String)

    the path to the file

Returns:

  • (Integer)

    XMP_FT_UNKNOWN on error or if the file type is unknown



125
# File 'lib/exempi/exempi.rb', line 125

attach_function :xmp_files_check_file_format, [ :string ], :int

#xmp_files_closeBoolean

Close an XMP file. Will flush the changes. xmp_get_error() will give the error code.

Parameters:

  • xf (FFI::Pointer, FFI::MemoryPointer)

    the file object

  • options (Exempi::XmpCloseFileOptions)

    the options to close.

Returns:

  • (Boolean)

    true on succes, false on error



93
# File 'lib/exempi/exempi.rb', line 93

attach_function :xmp_files_close, [ :pointer, XmpCloseFileOptions ], :bool

#xmp_files_freeBoolean

Free a XmpFilePtr. xmp_get_error() will give the error code.

Parameters:

  • xf (FFI::Pointer, FFI::MemoryPointer)

    the file ptr. Cannot be NULL

Returns:

  • (Boolean)

    false on error.



114
# File 'lib/exempi/exempi.rb', line 114

attach_function :xmp_files_free, [ :pointer ], :bool

#xmp_files_get_file_infoBoolean

Get the file info from the open file

Parameters:

  • xf (FFI::Pointer, FFI::MemoryPointer)

    the file object

  • filePath (FFI::Pointer, FFI::MemoryPointer)

    the file path object to store the path in. Pass NULL if not needed.

  • options (FFI::Pointer, FFI::MemoryPointer)

    the options for open. Pass NULL if not needed.

  • file_format (FFI::Pointer, FFI::MemoryPointer)

    the detected file format. Pass NULL if not needed.

  • handler_flags (FFI::Pointer, FFI::MemoryPointer)

    the format options like from %xmp_files_get_format_info.

Returns:

  • (Boolean)

    false in case of error.



108
# File 'lib/exempi/exempi.rb', line 108

attach_function :xmp_files_get_file_info, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :bool

#xmp_files_get_format_infoBoolean

Get the format info

Parameters:

  • format (Integer)

    type identifier

  • option (FFI::Pointer, FFI::MemoryPointer)

    the options for the file format handler

Returns:

  • (Boolean)

    false on error



120
# File 'lib/exempi/exempi.rb', line 120

attach_function :xmp_files_get_format_info, [ :int, :pointer ], :bool

#xmp_get_array_itemBoolean

Get an item frpm an array property

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the xmp meta

  • schema (String)

    the schema

  • name (String)

    the property name

  • index (Integer)

    the index in the array

  • property (FFI::Pointer, FFI::MemoryPointer)

    the property value

  • propsBits (FFI::Pointer, FFI::MemoryPointer)

    the property bits. Pass NULL is unwanted.

Returns:

  • (Boolean)

    TRUE if success.



219
# File 'lib/exempi/exempi.rb', line 219

attach_function :xmp_get_array_item, [ :pointer, :string, :string, :int32, :pointer, :pointer ], :bool

#xmp_get_localized_textBoolean

Get a localised text from a localisable property. Can be NULL or empty. not wanted.

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)

    the schema

  • name (String)

    the property name.

  • genericLang (String)

    the generic language you may want as a fall back.

  • specificLang (String)

    the specific language you want. Can’t be NULL or empty.

  • actualLang (FFI::Pointer, FFI::MemoryPointer)

    the actual language of the value. Can be NULL if

  • itemValue (FFI::Pointer, FFI::MemoryPointer)

    the localized value. Can be NULL if not wanted.

  • propBits (FFI::Pointer, FFI::MemoryPointer)

    the options flags describing the property. Can be NULL.

Returns:

  • (Boolean)

    true if found, false otherwise.



279
# File 'lib/exempi/exempi.rb', line 279

attach_function :xmp_get_localized_text, [ :pointer, :string, :string, :string, :string, :pointer, :pointer, :pointer ], :bool

#xmp_get_propertyBoolean

Get an XMP property and it option bits from the XMP packet

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)
  • name (String)
  • property (FFI::Pointer, FFI::MemoryPointer)

    the allocated XmpStringPtr

  • propsBits (FFI::Pointer, FFI::MemoryPointer)

    pointer to the option bits. Pass NULL if not needed

Returns:

  • (Boolean)

    true if found



204
# File 'lib/exempi/exempi.rb', line 204

attach_function :xmp_get_property, [ :pointer, :string, :string, :pointer, :pointer ], :bool

#xmp_has_propertyBoolean

Determines if a property exists in the XMP Packet provided

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)

    the schema of the property. Can’t be NULL or empty.

  • name (String)

    the name of the property. Can’t be NULL or empty.

Returns:

  • (Boolean)

    true is the property exists



265
# File 'lib/exempi/exempi.rb', line 265

attach_function :xmp_has_property, [ :pointer, :string, :string ], :bool

#xmp_iterator_nextBoolean

Iterate to the next value

Parameters:

  • iter (FFI::Pointer, FFI::MemoryPointer)

    the iterator

  • schema (FFI::Pointer, FFI::MemoryPointer)

    the schema name. Pass NULL if not wanted

  • propName (FFI::Pointer, FFI::MemoryPointer)

    the property path. Pass NULL if not wanted

  • propValue (FFI::Pointer, FFI::MemoryPointer)

    the value of the property. Pass NULL if not wanted.

  • options (FFI::Pointer, FFI::MemoryPointer)

    the options for the property. Pass NULL if not wanted.

Returns:

  • (Boolean)

    true if still something, false if none



320
# File 'lib/exempi/exempi.rb', line 320

attach_function :xmp_iterator_next, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :bool

#xmp_namespace_prefixBoolean

Check if a namespace is registered. NEW in 2.1

Parameters:

  • ns (String)

    the namespace to check.

  • prefix (FFI::Pointer, FFI::MemoryPointer)

    The prefix associated if registered. Pass NULL if not interested.

Returns:

  • (Boolean)

    true if registered.



142
# File 'lib/exempi/exempi.rb', line 142

attach_function :xmp_namespace_prefix, [ :string, :pointer ], :bool

#xmp_newFFI::Pointer

Create a new XMP packet

Parameters:

  • buffer (String)

    the buffer to load data from. UTF-8 encoded.

  • len (Integer)

    the buffer length in byte

Returns:

  • (FFI::Pointer)

    the packet pointer. Must be free with xmp_free()



158
# File 'lib/exempi/exempi.rb', line 158

attach_function :xmp_new, [ :string, :uint ], :pointer

#xmp_prefix_namespace_uriBoolean

Check if a ns prefix is registered. if not interested. NEW in 2.1

Parameters:

  • prefix (String)

    the prefix to check.

  • ns (FFI::Pointer, FFI::MemoryPointer)

    the namespace associated if registered. Pass NULL

Returns:

  • (Boolean)

    true if registered.



150
# File 'lib/exempi/exempi.rb', line 150

attach_function :xmp_prefix_namespace_uri, [ :string, :pointer ], :bool

#xmp_register_namespaceBoolean

Register a new namespace to add properties to. This is done automatically when reading the metadata block

Parameters:

  • namespaceURI (String)

    the namespace URI to register

  • suggestedPrefix (String)

    the suggested prefix

  • registeredPrefix (FFI::Pointer, FFI::MemoryPointer)

    the really registered prefix. Not necessarily %suggestedPrefix.

Returns:

  • (Boolean)

    true if success, false otherwise.



134
# File 'lib/exempi/exempi.rb', line 134

attach_function :xmp_register_namespace, [ :string, :string, :pointer ], :bool

#xmp_serializeBoolean

Serialize the XMP Packet to the given buffer

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP Packet

  • buffer (FFI::Pointer, FFI::MemoryPointer)

    the buffer to write the XMP to

  • options (Exempi::XmpSerialOptions)

    options on how to write the XMP. See XMP_SERIAL_*

  • padding (Integer)

    number of bytes of padding, useful for modifying embedded XMP in place.

Returns:

  • (Boolean)

    TRUE if success.



183
# File 'lib/exempi/exempi.rb', line 183

attach_function :xmp_serialize, [ :pointer, :pointer, XmpSerialOptions, :uint32 ], :bool

#xmp_serialize_and_formatBoolean

Serialize the XMP Packet to the given buffer with formatting

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP Packet

  • buffer (FFI::Pointer, FFI::MemoryPointer)

    the buffer to write the XMP to

  • options (Exempi::XmpSerialOptions)

    options on how to write the XMP. See XMP_SERIAL_*

  • padding (Integer)

    number of bytes of padding, useful for modifying embedded XMP in place.

  • newline (String)

    the new line character to use

  • tab (String)

    the indentation character to use

  • indent (Integer)

    the initial indentation level

Returns:

  • (Boolean)

    TRUE if success.



195
# File 'lib/exempi/exempi.rb', line 195

attach_function :xmp_serialize_and_format, [ :pointer, :pointer, XmpSerialOptions, :uint32, :string, :string, :int32 ], :bool

#xmp_set_localized_textBoolean

Set a localised text in a localisable property. Can be NULL or empty.

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)

    the schema

  • name (String)

    the property name.

  • genericLang (String)

    the generic language you may want to set too.

  • specificLang (String)

    the specific language you want. Can’t be NULL or empty.

  • value (String)

    the localized value. Cannot be NULL.

  • optionBits (Exempi::XmpPropsBits)

    the options flags describing the property.

Returns:

  • (Boolean)

    true if set, false otherwise.



291
# File 'lib/exempi/exempi.rb', line 291

attach_function :xmp_set_localized_text, [ :pointer, :string, :string, :string, :string, :string, XmpPropsBits ], :bool

#xmp_set_propertyBoolean

Set an XMP property in the XMP packet

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)
  • name (String)
  • value (String)

    0 terminated string

  • optionBits (Exempi::XmpPropsBits)

Returns:

  • (Boolean)

    false if failure



228
# File 'lib/exempi/exempi.rb', line 228

attach_function :xmp_set_property, [ :pointer, :string, :string, :string, XmpPropsBits ], :bool

#xmp_set_property_dateBoolean

Set a date XMP property in the XMP packet

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)
  • name (String)
  • value (FFI::Pointer, FFI::MemoryPointer)

    the date-time struct

  • optionBits (Exempi::XmpPropsBits)

Returns:

  • (Boolean)

    false if failure



237
# File 'lib/exempi/exempi.rb', line 237

attach_function :xmp_set_property_date, [ :pointer, :string, :string, :pointer, XmpPropsBits ], :bool

#xmp_set_property_floatBoolean

Set a float XMP property in the XMP packet

Parameters:

  • xmp (FFI::Pointer, FFI::MemoryPointer)

    the XMP packet

  • schema (String)
  • name (String)
  • value (Float)

    the float value

  • optionBits (Exempi::XmpPropsBits)

Returns:

  • (Boolean)

    false if failure



246
# File 'lib/exempi/exempi.rb', line 246

attach_function :xmp_set_property_float, [ :pointer, :string, :string, :double, XmpPropsBits ], :bool

#xmp_string_cstrString

Get the C string from the XmpStringPtr

Parameters:

  • s (FFI::Pointer, FFI::MemoryPointer)

    the string object

Returns:

  • (String)

    the const char * for the XmpStringPtr. It belong to the object.



308
# File 'lib/exempi/exempi.rb', line 308

attach_function :xmp_string_cstr, [ :pointer ], :string

#xmp_string_newFFI::Pointer

Instanciate a new string

Returns:

  • (FFI::Pointer)

    the new instance. Must be freed with xmp_string_free()



298
# File 'lib/exempi/exempi.rb', line 298

attach_function :xmp_string_new, [  ], :pointer