# wx.canvasToTempFilePath(Object object, Object this)

with Promise style call: Supported

Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6

Generates a specified size picture by exporting the contents of the specified area of the current canvas. in draw() Callback call this method to ensure that the picture export success.

# parameter

# Object object

attribute type Default values Required Introductions Minimum version
x number 0 no The upper-left abscissa of the specified canvas area 1.2.0
and number 0 no The upper-left ordinate of the specified canvas area 1.2.0
width number Canvas width - x no Width of the specified canvas area 1.2.0
height number Canvas height - y no Height of the specified canvas area 1.2.0
destWidth number width*Screen pixel density no Width of output picture 1.2.0
destHeight number height*Screen pixel density no Height of output picture 1.2.0
canvasId string no Canvas identity, passed in canvas Component canvas-id
canvas Object no Canvas identity, passed in canvas Component instance (canvas type="2d" This property is used when the.
fileType string png no Type of destination file 1.7.0
quality number no The quality of the picture is currently only jpg Effective. The range is (0, 1]When not within the scope of 1.0 Deal with. 1.7.0
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Interface calls the end of the callback function (call success or failure will be executed)

object.fileType Legal value

value Introductions Minimum version
jpg jpg picture
png png picture

# object.success callback

# parameter
# Object res
attribute type Introductions
tempFilePath string Temporary path to build file (Local path)

# Object this

Under a custom component, the this of the current component instance to manipulate within the component canvas assembly

# sample code


wx.canvasToTempFilePath({
  x: 100,
  and: 200,
  width: 50,
  height: 50,
  destWidth: 100,
  destHeight: 100,
  canvasId: 'myCanvas',
  success(res) {
    console.log(res.tempFilePath)
  }
})