Created
July 25, 2023 20:53
-
-
Save rtio/6a3e08d2b43b6078eefcf2f7af66654f to your computer and use it in GitHub Desktop.
Convert an image to a byte string
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
| <?php | |
| $webpFilePath = 'new.jpeg'; | |
| $byteArray = array_values(unpack('C*', file_get_contents($webpFilePath))); | |
| $byteString = implode(array_map('chr', $byteArray)); | |
| echo base64_encode($byteString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment