fetchImageThumbnail(params: Object)

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

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

Description

Get image thumbnail

Parameters

PropertyTypeRequiredDescription
originPathstringYesOriginal resource URL
thumbWidthnumberYesThumbnail width (px)
thumbHeightnumberYesThumbnail height (px)
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
PropertyTypeDescription
thumbnailPathstringThumbnail URL
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { downloadFile, fetchImageThumbnail } from '@ray-js/ray'

// Get image thumbnail: download the image first, then generate a thumbnail with the specified width and height
downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_image.jpg",
  success: ({ tempFilePath }) => {
    fetchImageThumbnail({
      originPath: tempFilePath,
      thumbWidth: 100,
      thumbHeight: 100,
      success: data => console.log("Thumbnail path:", data.thumbnailPath),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});