Пример первый:
1 2 3 |
test="$(cat NAME_FILE.JPG | base64)" echo $test |
Второй пример:
1 2 3 |
test=$( base64 NAME_FILE.JPG ) echo $test |
Третий пример:
1 2 3 |
base64 -w 0 NAME_FILE.JPG > NAME_FILE.JPG.base64 base64 -d NAME_FILE.base64 > NAME_FILE.JPG |
Четвертый пример вставка в HTML \ CSS \ XML \ XHTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
(X)HTML Image Embedding Example <img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." /> CSS Image Embedding Example div.image { width:100px; height:100px; background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...); } XML Image Embedding Example <image> <title>An Image</title> <link>http://www.your.domain</link> <url>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...</url> </image> Embed other stuff! Data URIs can potentially store any type of data, not just images! Try these examples on for size: (X)HTML CSS Embedding Example <link rel="stylesheet" type="text/css" href="data:text/css;base64,LyogKioqKiogVGVtcGxhdGUgKioq..." /> (X)HTML Javascript Embedding Example <script type="text/javascript" src="data:text/javascript;base64,dmFyIHNjT2JqMSA9IG5ldyBzY3Jv..."></script> |
Ссылки:
1 2 3 |
https://greywyvern.com/code/php/binary2base64 https://base64.guru/converter/decode/image https://ru.wikipedia.org/wiki/Base64 |