// http -> base64

export const getHttpUrlBase64 = (httpurl) => {
  return new Promise((resolve, reject) => {
    const createImg = new Image()
    createImg.crossOrigin = 'Anonymous'
    createImg.src = httpurl + '?v=' + Math.random()
    createImg.onload = () => {
      const canvas = document.createElement('canvas')
      const width = createImg.width
      const height = createImg.height
      canvas.width = width
      canvas.height = height
      canvas.getContext('2d').drawImage(createImg, 0, 0, width, height)
      resolve(canvas.toDataURL('image/jpeg'))
    }
  })
}