Code for Better Life

Code for Better Life

Copy Image in Clipbaord to Electron App

Hwaryong's photo
Hwaryong

Published on Apr 28, 2021

1 min read

TL;DR

This function returns a code of image source.

const copyImage = () => {
  const _ = clipboard.availableFormats('clipboard')
  if (_.includes('image/png') || _.includes('image/jpeg')) {
    return clipboard.readImage('clipboard').toDataURL()
  }
  else return false
}

I referred to this web page.

 
Share this