Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Ruby
Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SFTP
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
DH Key Exchange
DSA
LZW

 

 

 

 

 

 

 

Add/Replace XMP Properties

Ruby XMP sample program to add or replace simple properties.

Download Ruby Programming Example Scripts

# file: xmpAddProp.rb

require 'chilkat'

# Add/replace string properties in XMP metadata
# embedded in a JPG or TIF image file.
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)

# AddSimpleStr adds the string property under the correct 
# rdf:Description subtree.
#
# If the string property already exists, it is replaced,
# otherwise it is added.
# 
# If the rdf:Description subtree does not yet exist for the namespace,
# it is automatically created.  The Chilkat XMP component automatically
# recognizes standard namespaces such as "Iptc4xmpCore" and others
# and will use the correct URI in the rdf:Description node.

xmp.AddSimpleStr(xml,"Iptc4xmpCore:Location","Wheaton")
xmp.AddSimpleStr(xml,"Iptc4xmpCore:CountryCode","US")
xmp.AddSimpleStr(xml,"Iptc4xmpCore:AbcXyz","Junk")

# To use a non-standard namespace, add a namespace mapping:
xmp.AddNsMapping("Chilkat","http:#www.chilkatsoft.com/")

# Chilkat XMP creates an rdf:Description node automatically for the
# "Chilkat" namespace, and the URI used is from our mapping (above).
xmp.AddSimpleStr(xml,"Chilkat:AbcXyz","Junk")

# 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/newXmp.xml")







 

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

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