76.2.1
TruvideoSdkImageEditorPreset
TruvideoSdkImageEditorPresetThis class is part of the Truvideo SDK and is used to configure the image editor with specific settings before presenting it to the user.
There is 2 ways to configure this class:
Method 1:
imageURL: AURLpointing to the input image that will be edited.outputURL: AURLwhere the edited image will be saved.
let configuration = TruvideoSdkImageEditorPreset(
imageURL: imageUrl, // URL of the image to be edited
outputURL: outputUrl // URL where the edited image will be saved
)Method 2:
inputImage: image objectoutputURL: AURLwhere the edited image will be saved.
let configuration2 = TruvideoSdkImageEditorPreset(
image: inputImage, // UIImage to be edited
outputURL: outputUrl // URL where the edited image will be saved
)presentTruvideoSdkImageEditorView(preset:onComplete:)
presentTruvideoSdkImageEditorView(preset:onComplete:)This method is used to present the Truvideo image editor with a given preset configuration.
Parameters:
preset: An instance ofTruvideoSdkImageEditorPresetcontaining the configuration for the editor.onComplete: A closure that is called when the image editor finishes. It returns aresultobject that contains:editedImage: The editedUIImage. If editing fails, a default emptyUIImageis returned.editedImageURL: TheURLwhere the edited image is saved. This property is available on iOS 16.0 and later.
viewController.presentTruvideoSdkImageEditorView(
preset: configuration,
onComplete: { result in
// Process the edited image
let editedImage: UIImage = result.editedImage ?? UIImage()
if #available(iOS 16.0, *) {
let editedImageURL: URL = result.editedImageURL ?? URL(filePath: "")
}
}
)Example Usage :
import Foundation
import TruvideoSdkImage
import UIKit
class ImageModule : NSObject {
func editImage(inputUrl: URL , outputUrl: URL, viewCon:UIViewController){
let configuration = TruvideoSdkImageEditorPreset(
imageURL: inputUrl, // URL of the image to be edited
outputURL: inputUrl // URL where the edited image will be saved
)
// Optionally, you can configure the editor with an image object instead of a URL.
// let configuration2 = TruvideoSdkImageEditorPreset( image: inputImage,
// outputURL: outputUrl
// )
// Present the image editor
viewCon.presentTruvideoSdkImageEditorView( preset: configuration,
onComplete: { result in
// Handle image editor result
let editedImage: UIImage = result.editedImage ?? UIImage()
if #available(iOS 16.0, *) {
let editedImageURL: URL = result.editedImageURL ?? URL(filePath: "")
}
} )
}
}Last updated
Was this helpful?