Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Add/Replace XMP Array Property to JPEGDelphi sample code to add or replace an XMP array property in a JPEG image. procedure TForm1.Button4Click(Sender: TObject);
var
success : Integer;
numXmp: Integer;
xml: IChilkatXml;
sa: ICkStringArray;
begin
ChilkatXmp1.UnlockComponent('Anything for 30-day trial');
// Load a JPEG image file (which has no embedded XMP metadata yet).
success := ChilkatXmp1.LoadAppFile('cheese32.jpg');
if (success = 0) then
begin
ChilkatXmp1.SaveLastError('lastError.txt');
ShowMessage(ChilkatXmp1.LastErrorText);
end;
// Prepare an array property to be added to the XMP:
sa := ChilkatXmp1.NewCkStringArray();
sa.Append('cheese');
sa.Append('cheddar');
sa.Append('wedge');
sa.Append('wisconsin');
sa.Append('icon');
// How many XMP metadata docs are embedded in this image file?
numXmp := ChilkatXmp1.NumEmbedded;
if (numXmp = 0) then
begin
// Create a new XMP document
// (XML Reference: http://www.chilkatsoft.com/refdoc/xChilkatXmlRef.html)
xml := ChilkatXmp1.NewXmp();
// The array can be a 'bag', 'alt', or 'seq'
ChilkatXmp1.AddArray(xml,'bag','dc:subject',sa);
// Append the XMP to the JPG.
ChilkatXmp1.Append(xml);
// Save the JPG with embedded XMP metadata
ChilkatXmp1.SaveAppFile('cheeseWithXmp.jpg');
end
else
begin
// Fetch the 1st embedded XMP document.
xml := ChilkatXmp1.GetEmbedded(0);
// The array can be a 'bag', 'alt', or 'seq'
// If "dc:subject" already exists, it is replaced.
ChilkatXmp1.AddArray(xml,'bag','dc:subject',sa);
// Save the JPG with embedded XMP metadata
ChilkatXmp1.SaveAppFile('cheeseWithXmp.jpg');
end;
end;
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.