![]() Finally, we create a template and print it out to the standard output. Afterward, we check whether it’s an empty variable because the variable will be empty in case of unsupported formats. base64 - base64 encode/decode data and print to standard output. Then, we grab the image format using the file command and convert it to lowercase. # Print usage and exit if the file was not providedįmt=$(file "$1" | grep -iEo 'apng|bmp|gif|jpeg|png|webp' | head -n1 | tr '' '')įirst of all, we write the usage function in case of errors. We’ll provide it with the image file, and it should print the img element to the standard output: #!/bin/bashĮcho "Formats: APNG BMP GIF JPEG PNG WEBP" It should detect the image format automatically and use it as the MIME type. Mode: C tab-width: 4 indent-tabs-mode: nil c-basic-offset: 4 - /. We can write a shell script to create an img element and embed the Base64 data in it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |