vre2h/use-react-screenshot

Parameterise useScreenshot for alternate file types e.g. jpg

CraigChamberlain opened this issue · 5 comments

It might be useful to download a filetype other than png for example .jpg.

It shouldn't be too hard to achieve and could be an optional "options object"

At point of consumption:

const [image, takeScreenShot] = useScreenshot({ type: 'image/jpeg', quality: 1.0 });

In the source code:

const base64Image = croppedCanvas.toDataURL(type, quality) 

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL

vre2h commented

Hi Craig, hope you're doing great.

I somehow didn't see your issue and PR. Let me check everything and get back to you.

Sorry for ignoring you one more time.

vre2h commented

Resolved in #2

Thanks for adding the jpg option into createFileName()
Is it possible to change the quality setting to reduce the file size of the JPEG?