![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) AI Modify Existing Image with Text PromptSee more AI ExamplesUses an AI text prompt and uploaded image data to modify an existing image and receive the modified output.Note: This example requires Chilkat v11.4.0 or greater.
integer li_rc integer li_Success oleobject loo_BdImageData oleobject loo_Ai oleobject loo_AskParams li_Success = 0 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Load the data from an existing image. loo_BdImageData = create oleobject li_rc = loo_BdImageData.ConnectToNewObject("Chilkat.BinData") if li_rc < 0 then destroy loo_BdImageData MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_BdImageData.LoadFile("qa_data/jpg/kid_blue_coat.jpg") if li_Success = 0 then Write-Debug loo_BdImageData.LastErrorText destroy loo_BdImageData return end if loo_Ai = create oleobject li_rc = loo_Ai.ConnectToNewObject("Chilkat.Ai") loo_Ai.Provider = "openai" // Use your provider's API key. loo_Ai.ApiKey = "MY_API_KEY" // Choose a model. loo_Ai.Model = "gpt-5" loo_AskParams = create oleobject li_rc = loo_AskParams.ConnectToNewObject("Chilkat.JsonObject") loo_AskParams.UpdateString("image.output_format","jpeg") loo_Ai.SetAskParams(loo_AskParams) loo_Ai.InputAddImageData(loo_BdImageData,"") loo_Ai.InputAddText("Modify the image by replacing the blue coat with a Metallica T-shirt.") // Give the AI some time (2 minutes). loo_Ai.IdleTimeoutMs = 120000 // Ask the AI for image output. li_Success = loo_Ai.Ask("image") if li_Success = 0 then Write-Debug loo_Ai.LastErrorText destroy loo_BdImageData destroy loo_Ai destroy loo_AskParams return end if // Get the image response data.; li_Success = loo_Ai.GetOutputBd(loo_BdImageData) if li_Success = 0 then Write-Debug loo_Ai.LastErrorText destroy loo_BdImageData destroy loo_Ai destroy loo_AskParams return end if loo_BdImageData.WriteFile("c:/aaworkarea/out.jpg") Write-Debug "Success." // ------------------------------- // Sample Input: // ------------------------------- // |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.