cropImages

Requires:
BaseKit≥3.14.2@ray-js/ray≥1.5.30
Platforms:
iOSAndroid
import { cropImages } from '@ray-js/ray';

// Promise usage
try {
  const res = await cropImages({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Method signature
cropImages(params: )
Minimum SDK versions
iOSThingSmartBaseKitBizBundle
≥ 6.0.3
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 6.0.0

Description

Image cropping

Parameters

PropertyTypeRequiredDescriptionMinimum SDK versions
[]NoPath of the image to crop—
complete() => voidNoCompletion callback (executed on both success and failure)—
success(params: Object) => voidNoCallback on successful API call—
fail(params: Object) => voidNoFailure callback—
success callback parameters
PropertyTypeDescriptionMinimum SDK versions
fileListstring[]List of output image paths after cropping—
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { chooseImage, cropImages } from '@ray-js/ray'

// Select a photo from the album, then crop it.
chooseImage({
  count: 1,
  sourceType: ["album"],
  success: res => {
    cropImages({
      cropFileList: res.tempFilePaths.map(filePath => ({
        filePath,
        topLeftX: 0,
        topLeftY: 0,
        bottomRightX: 100,
        bottomRightY: 100,
        format: 0,
        rotate: 0,
        isFlip: 1,
        outputImageWidth: 100,
        outputImageHeight: 100,
      })),
      success: data => {
        console.log(data);
      },
      fail: error => {
        console.error(error);
      },
    });
  },
  fail: error => {
    console.error(error);
  },
});