Media APIs

getImageInfo

Get information about an image including dimensions, path, and orientation.

Overview

my.getImageInfo retrieves detailed information about an image, including its width, height, path, orientation, and format.

Sample Code

// Network picture path
my.getImageInfo({
  src: 'https://img.example.com/example.jpg',
  success: (res) => {
    console.log(JSON.stringify(res));
  }
});

// apFilePath from chooseImage
my.chooseImage({
  success: (res) => {
    my.getImageInfo({
      src: res.apFilePaths[0],
      success: (res) => {
        console.log(JSON.stringify(res));
      }
    });
  },
});

// Relative path
my.getImageInfo({
  src: 'image/api.png',
  success: (res) => {
    console.log(JSON.stringify(res));
  }
});

Parameters

The incoming parameter is of the Object type with the following attributes:

PropertyTypeRequiredDescription
srcStringNoPicture path, supporting network picture path, apFilePath path and relative path.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

PropertyTypeDescription
widthNumberPicture width (in px).
heightNumberPicture height (in px).
pathStringLocal path of picture.
orientationStringReturn picture orientation. Effective values are listed below.
typeStringReturn picture format.

Orientation Parameter Description

EnumeratorDescription
upDefault.
down180-Degree rotation.
leftRotate by 90 degree counterclockwise.
rightRotate by 90 degree clockwise.
up-mirroredSame as up except for flipping horizontally.
down-mirroredSame as down except for flipping horizontally.
left-mirroredSame as left except for flipping vertically.
right-mirroredSame as right except for flipping vertically.

Usage Notes

  • Supports network URLs, apFilePath (from my.chooseImage), and relative paths
  • Returns comprehensive image metadata including dimensions and orientation
  • Useful for validating image properties before upload or display