Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
<?php
$in = 'i.gif';
$out = 'i.html';
$fin = file_get_contents($in); // Получаем файл $in
$fout = base64_encode($fin); // Кодируем в base64
$html = '<img src="data:image/gif;base64,'.$fout.'">'; // Генерирует картинку для сохранения в html
file_put_contents($out, $html); // Сохраняем страницу
?>
<form method="post" enctype="multipart/form-data"><input type=file name=file><input type=submit></form>
<?php
if(isset($_FILES['file'])){
echo "<textarea style='width:100%;height:400px;'>url(data:{$_FILES['file']['type']};base64,
" . base64_encode(file_get_contents($_FILES['file']['tmp_name'])) . ')</textarea>';
}
#!/bin/sh
WIDTH=`sips -g pixelWidth $1 | tail -n1 | cut -d" " -f4`
HEIGHT=`sips -g pixelHeight $1 | tail -n1 | cut -d" " -f4`
echo ".favicon_png:{ background:url(data:image/png;base64,`base64 $1`) top left no-repeat;); height: ${HEIGHT}px; width: ${WIDTH}px; }" > $2
createfi.sh myimage.png mystyle.css#!/bin/sh
WIDTH=`sips -g pixelWidth $1 | tail -n1 | cut -d" " -f4`
HEIGHT=`sips -g pixelHeight $1 | tail -n1 | cut -d" " -f4`
BASE64=`base64 $1`
echo ".favicon_png:{ background:url(data:image/png;base64,${BASE64}) top left no-repeat;); height: ${HEIGHT}px; width: ${WIDTH}px; }" > $2
Image to URI, легкий способ конвертации