tencent cloud

Feedback

Last updated: 2024-07-12 19:13:05

    chooseImage

    This API is used via wx.chooseImage(Object object).
    Feature Description: Selects images from the local album or uses the camera to take photos.
    Parameter and Description: Object.
    Attribute
    Type
    Valid Values and Descriptions
    Default value
    Required
    Description
    count
    number
    -
    9
    No
    Maximum selectable number of images
    sizeType
    Array.<string>
    Original: Original image
    Compressed: Compressed image
    ['original', 'compressed']
    No
    Dimensions of the Selected Image
    sourceType
    Array.<string>
    Album: Select image from album
    Camera: Uses the camera
    ['album', 'camera']
    No
    Select image source
    success
    function
    -
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    tempFilePaths
    Array.<string>
    List of local temporary file paths for the image (Local Path)
    tempFiles
    Array.<string>
    List of local temporary files for the image
    Structure of res.tempFiles
    Attribute
    Type
    Description
    path
    string
    Local temporary file path
    size
    number
    Size of local temporary files, measured in bytes.
    Sample Code
    wx.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'],
    sourceType: ['album', 'camera'],
    success(res) {
    // tempFilePath can be used as the src attribute in an img tag to display the image
    const tempFilePaths = res.tempFilePaths
    }
    })

    compressImage

    This API is used via wx.compressImage(Object object).
    Feature Description: Image compression interface, with optional compression quality.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    src
    string
    -
    Yes
    Image path, the path of the image, supporting local paths and code package paths.
    quality
    number
    80
    No
    Compression quality, ranging from 0 to 100. The lower the value, the lower the quality and the higher the compression rate (only effective for jpg).
    compressedWidth
    number
    -
    No
    The width of the compressed image, in pixels (px). If not specified, it will default to proportional scaling based on compressedHeight.
    compressedHeight
    number
    -
    No
    The height of the compressed image, in pixels (px). If not specified, it will default to proportional scaling based on compressedWidth.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    tempFilePath
    string
    The temporary file path of the compressed image (local path).
    Sample Code
    wx.compressImage({
    src: '', // Image path
    quality: 80 // Compression quality
    })

    getImageInfo

    This API is used via wx.getImageInfo(Object object).
    Feature Description: Gets image information. For network images to work, the download domain must be configured first.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    src
    string
    -
    Yes
    The path of the image, which can be a relative path, temporary file path, storage file path, or network image path.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    width
    number
    Original width of the image, in pixels (px). Rotation is not considered.
    height
    number
    Original height of the image, in pixels (px). Rotation is not considered.
    path
    string
    Local path of image
    orientation
    string
    type
    string
    Image format
    Valid values for res.orientation
    Value
    Description
    up
    Default orientation (photographing horizontally with a mobile phone), corresponding to 1 in Exif, or without orientation information.
    up-mirrored
    Identical to 'up', but mirrored, corresponding to 2 in Exif.
    down
    Rotating 180 degrees, corresponding to 3 in Exif.
    down-mirrored
    Identical to 'down', but mirrored, corresponding to 4 in Exif.
    left-mirrored
    Identical to 'left', but mirrored, corresponding to 5 in Exif.
    right
    Rotating 90 degrees clockwise, corresponding to 6 in Exif.
    right-mirrored
    Identical to 'right', but mirrored, corresponding to 7 in Exif.
    left
    Rotating 90 degrees counterclockwise, corresponding to 8 in Exif.
    The legal value of res.type
    Legal value
    Description
    unknown
    unknown format
    jpeg
    jpeg compression format
    png
    png compression format
    gif
    gif compression format
    tiff
    tiff compression format
    Sample Code
    wx.getImageInfo({
    src: 'images/a.jpg',
    success(res) {
    console.log(res.width)
    console.log(res.height)
    },
    })
    
    wx.chooseImage({
    success(res) {
    wx.getImageInfo({
    src: res.tempFilePaths[0],
    success(res) {
    console.log(res.width)
    console.log(res.height)
    },
    })
    },
    })

    previewImage

    This API is used via wx.previewImage(Object object).
    Feature Description: Full-screen image preview in a new page. During the preview, users can save the image, share it with friends, and perform other operations.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    urls
    Array.<string>
    -
    Yes
    List of image links to be previewed. Cloud file ID is supported.
    current
    string
    The first one in urls.
    No
    The link to the currently displayed image.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    wx.previewImage({
    current: '', // The HTTP link to the currently displayed image.
    urls: [], // List of HTTP image links to be previewed.
    })

    previewMedia

    This API is used via wx.previewMedia(Object object).
    Feature Description: Previews images and videos.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    sources
    Array.<Object>
    
    Yes
    List of resources to preview
    current
    number
    0
    No
    Serial number of the currently displayed resource
    filePath
    string
    -
    Yes
    Image file path, can be temporary file path or permanent file path (local path), does not support network image paths
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)

    saveImageToPhotosAlbum

    This API is used via wx.saveImageToPhotosAlbum(Object object).
    Note:
    Prior to invocation, user authorization "scope.writePhotosAlbum" is required.
    Feature Description: Saves images to the system album.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    filePath
    string
    -
    Yes
    Image file path, can be temporary file path or permanent file path (local path), does not support network image paths
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    wx.saveImageToPhotosAlbum({
    success(res) {},
    })
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support