Created
July 6, 2023 03:08
-
-
Save davigmacode/c271204f863693d00d4102bf9b09af71 to your computer and use it in GitHub Desktop.
React get blob from loaded image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <img | |
| crossOrigin="anonymous" | |
| onLoad={(e) => { | |
| const canvas = document.createElement('canvas'); | |
| const ctx = canvas.getContext('2d'); | |
| ctx?.drawImage(e.currentTarget, 0, 0); | |
| canvas.toBlob((blob) => blob && doSomeThing(blob)); | |
| }} | |
| /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment