Image Editing

This documentation outlines the guidelines for utilizing the Image Module SDK, which offers powerful image editing tools. The SDK provides straightforward methods to incorporate advanced image editing functionalities into your

Prerequisites

  • Ensure you have integrated the TruVideo Core SDK into your project and completed with the authentication process

  • Camera module will provide MediaItem or simply provide filepath to upload (optional)

Edit an Image

To edit an image, follow these steps:

Step 1 : Get Result File path where to place the save image

This function returns the result path using the provided file name as input.

const resultPathResponse = await getResultPath(`${Date.now()}-editImage.png`);

Step 2 : Call Image Edit

After obtaining the result path, invoke the launchImageEdit function to edit

// result path will be available from step 1
// media item will be get from camera module or pass string file path
const payload = {
    inputPath: filePath,
    outputPath: resultPathResponse.result,
};
const { result } = await TruvideoSdkImage.editImage(payload);
console.log("Edit Image Response:", result);

Finalize :

After completing this steps the function should look like

import { TruvideoSdkImage } from '@trunpm/truvideo-capacitor-image-sdk'
import { getResultPath } from '@trunpm/truvideo-capacitor-video-sdk';

async function imageEditing() {
    try {
      const resultPathResponse = await getResultPath(`${Date.now()}-editImage.png`);
      
      const payload = {
        inputPath: filePath,
        outputPath: resultPathResponse.result,
      };
 
      const { result } = await TruvideoSdkImage.editImage(payload);
      console.log("Edit Image Response:", result);
    } catch (error) {
      console.error("❌ Failed to Edit Image:", error);
    } finally {

    }
  }

}

Learn More

Explore advanced capabilities of the Image Module in the Image Module Reference.

Last updated

Was this helpful?