Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Ruby
Examples

Quick Start
Ruby Unicode
Ruby Byte Array
Ruby Certs
Ruby Email
Ruby Encryption
Ruby FTP
HTML-to-XML
Ruby HTTP
Ruby IMAP
Ruby MHT
Ruby MIME
Ruby S/MIME
Ruby Signatures
Ruby RSA
Ruby Socket
Ruby Spider
Ruby Tar
Ruby Upload
Ruby XML
Ruby XMP
Ruby Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
LZW
Bz2
Icon

 

 

 

 

 

 

 

Add / Delete XMP Structure Property Fields

Ruby example to add, update, or delete structure property field values.

Download Ruby Programming Example Scripts

# file: xmpAddDelStruct.rb

require 'chilkat'

# Add and delete fields within structure properties.
xmp = Chilkat::CkXmp.new()
success = xmp.UnlockComponent("Anything for 30-day trial")
if not success
	xmp.SaveLastError("errorLog.txt")
	exit
end

success = xmp.LoadAppFile("images/xmpExample.jpg")
if not success
	xmp.SaveLastError("errorLog.txt")
	exit
end

# How many embedded XMP documents in the image file?
numEmbedded = xmp.get_NumEmbedded()
if (numEmbedded == 0) 
	print "This JPG does not have embedded XMP metadata\n"
	exit
end

# Retrieve the 1st XMP document as a CkXml object.
# (There is usually only a single embedded XMP)
xml = xmp.GetEmbedded(0)

# Remove the Iptc4xmpCore:CiEmailWork in the Iptc4xmpCore:CreatorContactInfo structure.
xmp.RemoveStructProp(xml,"Iptc4xmpCore:CreatorContactInfo","Iptc4xmpCore:CiEmailWork")

# AddStructProp updates the property value if it already exists.
xmp.AddStructProp(xml,"Iptc4xmpCore:CreatorContactInfo","Iptc4xmpCore:CiAdrCity","Chicago")

# Add if does not already exist:
xmp.AddStructProp(xml,"Iptc4xmpCore:CreatorContactInfo","Iptc4xmpCore:Comments","Hello World!")

# Create entirely new structure w/ 1st member if the structure does not yet exist.
xmp.AddStructProp(xml,"Iptc4xmpCore:MyCustumStruct","AbcXyz","1234")

# Save the JPG with its updated XMP metadata.
xmp.SaveAppFile("output/out.jpg")

# Save the XMP to an XML file so we can review the changes in a text editor
xml.SaveXml("output/modifiedXmp.xml")









 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.