Created
July 30, 2013 03:48
-
-
Save kodaka/6110071 to your computer and use it in GitHub Desktop.
convert file to data URI
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use File::Slurp; | |
use MIME::Base64; | |
use Plack::MIME; | |
my $file = shift or die "usage: $0 file¥n"; | |
my $mime = Plack::MIME->mime_type($file) or die "Cannot find MIME type for $file"; | |
printf 'data:%s;base64,%s', $mime, encode_base64(read_file($file, { binmode => ':raw' }), q{}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment