Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) 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.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @xmp int -- Use "Chilkat_9_5_0.Xmp" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Xmp', @xmp OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' 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... DECLARE @success int 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 EXEC @hr = sp_OADestroy @xmp 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 EXEC @hr = sp_OADestroy @xmp RETURN END EXEC sp_OAMethod @xmp, 'Append', @success OUT, @xml IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xmp, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @xmp RETURN END EXEC sp_OAMethod @xmp, 'SaveAppFile', @success OUT, 'screamOut.jpg' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @xmp, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @xmp RETURN END EXEC @hr = sp_OADestroy @xmp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.