Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Add XMP MetaData to JPG or TIFFDemonstrates how to add XMP metadata to a JPG or TIFF image that doesn't already have XMP metadata. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @xmp int EXEC @hr = sp_OACreate 'Chilkat.Xmp', @xmp OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @xmp, 'UnlockComponent', @success OUT, 'Anything for 30-day trial.' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xmp, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END DECLARE @xml int -- The first step is to create a new XMP document, which is nothing -- more than XML. The NewXmp method returns an XML document with -- the standard XMP boilerplate. EXEC sp_OAMethod @xmp, 'NewXmp', @xml OUT -- Add some properties... EXEC sp_OAMethod @xmp, 'AddSimpleStr', @success OUT, @xml, 'Iptc4xmpCore:Chilkat', 'Blah blah' -- If you wish to view the XML, save it to a file and review it -- with a text editor: EXEC sp_OAMethod @xml, 'SaveXml', @success OUT, 'newXmp.xml' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xml, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- To add the XMP to the JPG (or TIFF), simply load the JPG, -- append the XMP, and save: EXEC sp_OAMethod @xmp, 'LoadAppFile', @success OUT, 'scream.jpg' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xmp, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END EXEC sp_OAMethod @xmp, 'Append', @success OUT, @xml IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xmp, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END EXEC sp_OAMethod @xmp, 'SaveAppFile', @success OUT, 'screamOut.jpg' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xmp, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.