tencent cloud

Feedback

Last updated: 2024-03-05 15:26:42

    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.
    Original: Original image
    Compressed: Compressed image
    ['original', 'compressed']
    No
    Dimensions of the Selected Image
    sourceType
    Array.
    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.
    List of local temporary file paths for the image (Local Path)
    tempFiles
    Array.
    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.
    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.
    Type
    Default value
    Required
    Description
    Array.<Object>
    -
    Yes
    List of resources to be previewed.
    number
    0
    No
    The sequence number of the currently displayed resource.
    boolean
    true
    No
    Whether to display long-press menu.
    string
    no-referrer
    No
    Origin: Sends the complete referrer.
    No-referrer: Not to send.
    The format is fixed as https://servicewechat.com/{appid}/{version}/page-frame.html, wherein
    {appid} represents the appid of the mini program.
    {version} is the version number of the mini program. A version number of 0 indicates a development version, trial version, or review version. A version number of devtools indicates a developer tool, and the rest are official versions.
    function
    -
    No
    Callback Function of Successful Interface Call
    function
    -
    No
    Callback Function of Failing Interface Call
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Code that supports long-press recognition
    Type
    Description
    Mini Program Code
    -
    WeChat personal code at host client
    Does not support mini games.
    WeCom personal code at host client
    Does not support mini games.
    General Group Code
    Exclusively includes WeChat user groups within the host client, not supporting mini games.
    Intercommunicating Group Code
    Refers to groups within the host client that include both WeChat and WeCom users, not supporting mini games.
    WeChat Official Account QR Code.
    Does not support mini games.

    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
    The image file path can be a temporary or permanent file path, not supporting 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) {},
    })

    chooseMessageFile

    This API is used via wx.chooseMessageFile(Object object).
    Feature Description: Selects files from the client session.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    count
    number
    -
    Yes
    The maximum number of files that can be selected ranges from 0 to 100.
    type
    string
    all
    Yes
    The type of the selected file, whose valid values are:
    all: Select from all files.
    video: Only video files can be selected.
    image: Only image files can be selected.
    file: Other files excluding images and videos can be selected.
    extension
    Array.<string>
    -
    No
    Filter based on file extension, effective only when type==file. Each item must not be an empty string. By default, no filtering is applied.
    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
    tempFile
    Array.<string>
    Returns an array of local temporary file objects for the selected files.
    Structure attribute of tempFile
    Structure attributes
    Type
    Description
    path
    string
    Local Temporary File Path (Local Path)
    size
    number
    Size of local temporary files, measured in bytes.
    name
    string
    Name of selected file
    type
    string
    Type of selected file, whose valid values include:
    video: Video files are selected.
    image: Image files are selected.
    file: Files excluding images and videos are selected.
    time
    number
    The sending time of the selected file's session, Unix timestamp. This attribute is currently not supported by the tool.
    
    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