docs: function resample(image, width, height) {
      let factor
  
      if (!width && !height) {
          width = image.width
          height = image.height
      }
  
      if (!width) {
          factor = height / image.height
          width = Math.round(image.width * factor)
      }
  
      if(!height) {
          factor = width / image.width
          height = Math.round(image.height * factor)
      }
  
      let canvas = image
      while(canvas.width > width && canvas.width * 0.5 > width) {
          canvas = scalingHelper(canvas, 0.5)
      }
  
      let finalCanvas = document.createElement('canvas')
      finalCanvas.width = width // 原始宽
      finalCanvas.height = height
      let ctx = finalCanvas.getContext('2d')
      ctx.drawImage(canvas, 0, 0, width, height)
  
      return finalCanvas
  }