The base64_encode() function is an inbuilt function in PHP which is used to convert any data to base64 encoding. In order to convert an image into base64 encoding firstly need to get the contents of file. This can be done with the help of file_get_contents() function of PHP. Then pass this raw data to base64_encode() function to encode.
- base64_encode() Function The base64_encode() function is an inbuilt function in PHP which is used to Encodes data with MIME base64. MIME (Multipurpose Internet Mail Extensions) base64 is used to encode the string in base64. The base64_encoded data takes 33% more space then original data.
- file_get_contents() Function The file_get_contents() function in PHP is an inbuilt function which is used to read a file into a string. The function uses memory mapping techniques which are supported by the server and thus enhances the performances making it a preferred way of reading contents of a file.
- Convert an image into grayscale image using HTML/CSS
- Convert an image into Blur using HTML/CSS
- How to convert a PDF document to a preview image in PHP?
- Getting started with Scikit-image: image processing in Python
- HTML | URL Encoding
- CSS | Image Gallery
- Saving an Image from URL in PHP
- What is Image Blurring
- CSS | Image Sprites
- CSS | background-image Property
- jQuery | :image Selector
- How to change color of PNG image using CSS?
- Resize image proportionally with CSS
- HTML | DOM Image Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.