Created
December 2, 2018 21:07
-
-
Save Downes/aaf82d5e1097ac46e3dd79b2c340bc09 to your computer and use it in GitHub Desktop.
Encoding an image into Base64 in Perl for gRSShopper
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
if ($filerecord->{file_dirname} eq "image/png") { | |
my $imgfilename = $Site->{st_urlf}.$filerecord->{file_dirname}; | |
use File::Slurp; | |
use MIME::Base64 qw|encode_base64|; | |
$imagestr = encode_base64( read_file( $imgfilename ) ); | |
$imagestr =~ s/\n//g;$imagestr =~ s/\n//g; # because they get inserted somehow and Badgr chokes on them | |
$imagestr = "data:image/png;base64,".$imagestr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment