Created
January 30, 2011 15:07
-
-
Save Cifro/802922 to your computer and use it in GitHub Desktop.
PNG -> DataURI in LESS syntax
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
<title>PNG -> DataURI in LESS syntax</title> | |
<form method=post> | |
<input type="text" size="150" name="folder"> | |
<input type="submit" value="Go"> | |
</form> | |
<pre> | |
<?php | |
// save output to e.g. icons.less | |
// and in main file add: | |
// @import "icons.less"; | |
if(isset($_POST['folder'])){ | |
$folder = $_POST['folder']; | |
foreach(glob("$folder/*.png") as $file){ | |
$f = file_get_contents($file); | |
$file = preg_replace("/(-\d+)/", "", $file); | |
echo "@" . strtolower(basename($file, '.png')) . '-icon: "data:image/png;base64,' . base64_encode($f) . '";' . "\n"; | |
} | |
echo "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment